简体   繁体   English

是否可以在所有应用程序的后台运行语音识别

[英]Is it possible to have voice recognition run in background of all apps

Is it possible to add a service to an app being launched by packagemanager? 是否可以向packagemanager发布的应用添加服务? I am using the following code to launch an app 我使用以下代码来启动应用程序

       Intent p;
        PackageManager manager = getPackageManager();
        try{
            p = manager.getLaunchIntentForPackage("com.wificonnection.booster92_2017-09-07");
            if(p == null)
                throw new PackageManager.NameNotFoundException();
            p.addCategory(Intent.CATEGORY_LAUNCHER);
            startActivity(p);
        }catch(PackageManager.NameNotFoundException e){

        }

I have a speechrecognition service also and I would like the speechrecognition service to run in the background of the launched app so I can close the app and change the view by voice command. 我还有语音识别服务,我希望语音识别服务在启动的应用程序的后台运行,这样我就可以关闭应用程序并通过语音命令更改视图。 Is this possible? 这可能吗? If so how would I implement this? 如果是这样我将如何实现?

The code I am working with is from this project https://github.com/hypeapps/black-mirror 我正在使用的代码来自这个项目https://github.com/hypeapps/black-mirror

Also I am using Androidthings for this project. 我也在为这个项目使用Androidthings。

In an AndroidThings project, your app is the only app ever running. 在AndroidThings项目中,您的应用是唯一运行的应用。

So yes you can running a background service and do whatever you want. 所以是的,你可以运行后台服务并做任何你想做的事情。 It will not be interrupted as you are the only Application (and Activity) running on that device. 它不会被中断,因为您是该设备上运行的唯一应用程序(和活动)。

So follow best practices of service binding https://developer.android.com/guide/components/services and you will be fine 请遵循服务绑定的最佳做法https://developer.android.com/guide/components/services ,你会没事的

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM