简体   繁体   中英

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? 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

Also I am using Androidthings for this project.

In an AndroidThings project, your app is the only app ever running.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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