daleyjem
daleyjem

Reputation: 2674

How to launch android voice search from NFC

I have an NFC writer app installed to write to a tag, but the voice search app isn't listed in the list of apps to choose from. I have the option to launch an app from an app uri, but not sure if that's what I need. If it is, what is the uri that I must use?

Upvotes: 0

Views: 591

Answers (3)

Eric
Eric

Reputation: 21

I'm using nfc task launcher, Make a new task and add an "open activity" action from the applications and shortcuts action menu.

Then select Google as the application and set "Com.google.android.googlequicksearchboxVoiceSearchActivity" as the activity.

Then save the task to an nfc tag and you're all set. If you want to take it further you can download home 2 switcher and set it up to run that task on a double home key press which is what I did. Hope that helps!

Upvotes: 2

NFC guy
NFC guy

Reputation: 10228

Voice search is not a separate app, it is just one Activity in the Google app. To start it, you need to launch the SearchActivity from the package com.google.android.googlequicksearchbox with action android.intent.action.SEARCH_LONG_PRESS. This cannot be done directly from an NFC tag, because intents generated by an NFC tag have always a different action (for example android.nfc.action.NDEF_DISCOVERED). So you will have to write your own app for this.

Upvotes: 0

shubham5263
shubham5263

Reputation: 61

use nxp tag writer app, to write the desired app on your tag.

If the app is not listed on the list, you get to see. You can alternately write the app name along with the package name.

you can use this code to get the package name of any app, which is running in the foreground.

ActivityManager mActivityManager = (ActivityManager)    
getSystemService(Context.ACTIVITY_SERVICE);
        List<ActivityManager.RunningTaskInfo> RunningTask = mActivityManager
                .getRunningTasks(1);
        ActivityManager.RunningTaskInfo ar = RunningTask.get(0);

        String foregroundApp = ar.topActivity.getClassName().toString();

hope, it will work.

Upvotes: 0

Related Questions