简体   繁体   English

如何使用记笔记语音操作创建Android Wear应用程序?

[英]How to create an Android Wear app with the note-taking voice action?

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. 我似乎无法弄清楚如何创建一个Android Wear应用程序,它允许我通过内置的语音操作使用它来记笔记。 I declare the intent filter as stated in Adding Voice Capabilities : 我声明了添加语音功能中所述的intent过滤器:

<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. 但是,这没有任何作用,手机上的Wear应用程序不允许我将应用程序设置为默认的笔记记录应用程序。 What do I need to do to make that happen? 我需要做些什么来实现这一目标?

The trick is to include the category android.intent.category.DEFAULT , as stated in the documentation on intents . 诀窍是包含类别android.intent.category.DEFAULT ,如意图文档所述 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 . 除此之外,包含MIME类型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 answer with add this line also. @Malcolm回答同时添加此行。 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"/>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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