Do I need an intent to open Google Voice Search?

1

I need an intent to open Google voice search by a button, for that I need to place an Intent in MainActivity .

Intent open3 = getPackageManager().getLaunchIntentForPackage("com.google.android.googlequicksearchbox.VoiceSearchActivity");
    startActivity(open3);

Try using the packageName of Voice Search, it works on some devices but not on others, because some devices have Voice Search with another PackageName .

    
asked by Alejandro Matos 12.09.2017 в 00:41
source

1 answer

0

The correct intent to initialize Google Voice Search is using RecognizerIntent.ACTION_RECOGNIZE_SPEECH :

example:

private static final int CODE = 100;

Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
startActivityForResult(intent, CODE);

Obviously define a code that you want to use when receiving the answer in onActivityResult() .

    
answered by 12.09.2017 в 00:44