android - Multiple voice triggers to start the same Activity on Glass and distinguish which one was used -


I would like to use two different voice triggers to open the same activity, and within this activity, the decision Take what the trigger was used

Is it possible without adding an additional signal? According to the docs, you have access to RecognizerIntent.EXTRA_RESULTS , if any prompt is used

So my question is, does the same activity trigger more than one trigger Is it possible to fire with, and what code is there any way to know which trigger was used? After doing that I found a better way with activity-aka and meta-data.

Add an activity in which your AndroidManifest.xml first sounds trigger:

  & amp; Activity Activity: Name = "com.package.MainActivity" & gt; & Lt; Intent-Filter & gt; & Lt; Action Android: name = "com.google.android.glass.action.VOICE_TRIGGER" /> & Lt; / Intent-Filter & gt; & Lt; Meta-Data Android: name = "com.google.android.glass.VoiceTrigger" Android: resource = "@xml / glass_first_trigger" /> & Lt; / Activity & gt; After that, add an activity-nickname that includes the second trigger  
   & Lt; / Intent-Filter & gt; & Lt; Meta-Data Android: name = "com.google.android.glass.VoiceTrigger" Android: resource = "@xml / glass_second_trigger" /> & Lt; / Activity alias & gt; Then, on the code, you can read the meta-data values ​​and decide that:   activityInfo activityInfo = getPackageManager (). GetActivityInfo (getComponentName), PackageManager.GET_ACTIVITIES | PackageManager.GET_META_DATA); Int secondVoiceTrigger = activityInfo.metaData.getInt ("com.google.android.glass.VoiceTrigger"); If (secondVoiceTrigger == R.xml.glass_second_trigger) {// do different things}  

Comments

Popular posts from this blog

sqlite3 - UPDATE a table from the SELECT of another one -

c# - Showing a SelectedItem's Property -

javascript - Render HTML after each iteration in loop -