3

I can't seem to figure out how to create an Android Wear application which would allow me to use it to take notes via built-in voice actions. I declare the intent filter as stated in Adding Voice Capabilities:

<intent-filter>
    <action android:name="android.intent.action.SEND"/>
    <category android:name="com.google.android.voicesearch.SELF_NOTE"/>
</intent-filter>

However, that does nothing, and the Wear app on the phone doesn't allow me to set the application as the default note-taking app. What do I need to do to make that happen?

Malcolm
  • 41,014
  • 11
  • 68
  • 91

2 Answers2

5

The trick is to include the category android.intent.category.DEFAULT, as stated in the documentation on intents. If it is missing, no implicit intents can be received by the app. Besides that, it is important to include the MIME type text/plain. The complete declaration is as follows:

<intent-filter>
    <action android:name="android.intent.action.SEND"/>
    <category android:name="android.intent.category.DEFAULT"/>
    <category android:name="com.google.android.voicesearch.SELF_NOTE"/>

    <data android:mimeType="text/plain"/>
</intent-filter>
Malcolm
  • 41,014
  • 11
  • 68
  • 91
  • What else did you need to do for this to work? I had it working at one point using this intent filter, but for some reason I just cannot get the Android Wear app to recognize other apps anymore. Another other tips, suggestions, etc.? – Nlinscott Dec 03 '14 at 04:58
  • @Nlinscott Do you mean that you can add only one note-taking app this way? Not sure what you are trying to say. The other app shouldn't go anywhere, you should be able to switch between them in Android Wear. – Malcolm Dec 03 '14 at 05:00
  • Sorry, by "other apps" I meant the app I deployed with this intent filter. It wont let me assign anything to the "take a note" action, even with this app which has your intent filter. – Nlinscott Dec 03 '14 at 20:58
  • I even tried to launch an intent from the [ADB](http://xgouchet.fr/android/index.php?article42/launch-intents-using-adb). It brought up a chooser with my app in the list when i specified some of the intents here but Android Wear still wont recognize it. – Nlinscott Dec 03 '14 at 21:18
  • @Nlinscott Is the app installed on the Wear device and is it properly synchronized with the phone? – Malcolm Dec 05 '14 at 04:37
  • I fixed it, apparently there was some kind of BLE connectivity issue between my phone and Moto360. The Android Wear app wasn't properly synchronizing with the watch and didn't recognize the app. Restarting everything and setting it up properly solved my problem. – Nlinscott Dec 08 '14 at 04:44
  • We need to add this also. – Mohamed Ibrahim Nov 03 '15 at 07:38
2

@Malcolm answer with add this line also. It will be working fine.

<action android:name="com.google.android.gm.action.AUTO_SEND" />

The full part is

<intent-filter>
<action android:name="android.intent.action.SEND"/>
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="com.google.android.voicesearch.SELF_NOTE"/>
<action android:name="com.google.android.gm.action.AUTO_SEND" />
<data android:mimeType="text/plain"/>

Mohamed Ibrahim
  • 841
  • 11
  • 9