小编Sus*_*dal的帖子

语音识别作为后台服务

是否可以将活动作为服务实施?我的活动是语音识别活动.我希望在应用程序的后台运行活动,不断检查语音,当用户说出命令时,它会识别它,然后执行操作.我的问题是......是否可以这样做,如果是这样,后台服务如何通知当前活动或应用程序?之前有一篇帖子没有明确的答案......感谢您的任何意见或帮助.以下是来自另一个StackOverflow帖子的语音活动:

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.speech.RecognitionListener;
import android.speech.RecognizerIntent;
import android.speech.SpeechRecognizer;
import android.widget.Button;
import android.widget.TextView;
import java.util.ArrayList;
import android.util.Log;



public class voiceRecognitionTest extends Activity implements OnClickListener 
{

   private TextView mText;
   private SpeechRecognizer sr;
   private static final String TAG = "MyStt3Activity";
   @Override
   public void onCreate(Bundle savedInstanceState) 
   {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.main);
            Button speakButton = (Button) findViewById(R.id.btn_speak);     
            mText = (TextView) findViewById(R.id.textView1);     
            speakButton.setOnClickListener(this);
            sr = SpeechRecognizer.createSpeechRecognizer(this);       
            sr.setRecognitionListener(new listener());        
   }

   class listener implements RecognitionListener          
   {
            public void onReadyForSpeech(Bundle params)
            { …
Run Code Online (Sandbox Code Playgroud)

service android voice background-service voice-recognition

15
推荐指数
1
解决办法
1万
查看次数

Python 3:如何为派生类编写 __iter__ 方法,以便它扩展基类的 __iter__ 方法的行为

假设我有一个基类:

class Base:
    A = False
    B = ''
    C = ''

    def __iter__(self):
        yield 'a', self.A
        yield 'b', self.B
        yield 'c', self.C
Run Code Online (Sandbox Code Playgroud)

然后是一个从这个基派生的类:

class Data(Base):
    D = ''

    def __iter__(self):
        yield 'd', self.D
Run Code Online (Sandbox Code Playgroud)

这当然只创建一个包含{ 'd': <value> }on的字典dict( Data() ),当数据类的实例转换为dict类型时;因为据我所知,派生类__iter__方法有效地覆盖了基类__iter__方法。

然后我尝试从派生类覆盖的方法中调用基类方法,就像我们在__init__()函数中所做的那样:

def __iter__(self):
    super().__iter__()
    yield 'd', self.D
Run Code Online (Sandbox Code Playgroud)

但是 IDE 将其标记为错误。为什么这不起作用?以及如何定义派生的 iter 方法来扩展已经存在的基类 iter 方法,以便我只需要为派生类中添加的变量添加 yield?是否在派生类 iter 方法中再次手动写出所有收益,这是目前我实现它的唯一解决方案?为什么?

class Data(Base):
    D = ''

    def __iter__(self):
        yield 'a', self.A
        yield …
Run Code Online (Sandbox Code Playgroud)

python inheritance overriding iterable

5
推荐指数
1
解决办法
1300
查看次数

Flux 查询语言中 SELECT &lt;某些列&gt; 的等价物是什么?

什么是等效通量查询SELECT address, name FROM addresses?(我指的是由 InfluxData 开发的新查询语言 FluxQL)

我在有限的 Flux 文档中没有找到明确的答案。Flux 文档说filter()function 等同于 both SELECTandWHERE子句,但是给出的所有示例都等同于WHERE子句,在 上没有任何内容SELECT

这些是 FluxQL 的文档,以便更好地参考:

https://docs.influxdata.com/flux/v0.50/introduction/getting-started

https://v2.docs.influxdata.com/v2.0/query-data/get-started/

influxdb influxdb-2

5
推荐指数
1
解决办法
3322
查看次数

Android Studio:Google存储库更新失败.无法读取或创建安装属性文件

我正在运行Archlinux系统,我的用户帐户已读取Android SDK和Android Studio文件夹的写入权限/opt/.我收到这些错误:

[76583] WARN - dea.updater.SdkComponentSource - 无法加载文件/home/enlighter/.android/repositories.cfg.[77786] WARN - roid.tools.ndk.GradleWorkspace - 项目"MyApplication"的NDK支持被禁用,因为该项目不包含任何有效的本机配置.WARN - dea.updater.SdkComponentSource - 无法加载文件/home/enlighter/.android/repositories.cfg.

当我尝试将Google存储库从当前版本35更新到版本36时,我收到此错误:

WARN - ectedPackagesStep $ CustomLogger - 无法读取或创建安装属性文件.

即使没有下载所需的文件,更新也会失败.我该如何解决?

linux android android-studio

4
推荐指数
1
解决办法
5987
查看次数