Google Now采用蓝牙广播

时间:2014-07-17 17:55:34

标签: android bluetooth

我尝试使用来自网络的热门代码获取蓝牙按钮按键。 也在这个帖子中Capture media button on Android >=4.0 (works on 2.3)

但谷歌现在回应它(虽然我的应用程序在前台)无法实现这一点。 我做了什么: (env nexus 4,android 4.4.4)

  1. 关闭谷歌现在设置首选项'蓝牙耳机录制' (不确定确切的名称是因为我没有在英语中使用它 - 看起来像一个错误 - 它已经关闭并仍然谷歌搜索正在响应

  2. 现在关闭谷歌 - 我认为这是另一个错误 - 它已经关闭,仍然响应我的蓝牙按钮。

  3. 在我的应用中:

    1. 拥有正确的BT权限

    2. 清单文件中的
    3. - 通过以下方式注册接收方:

       

    4. 在我的应用onCreate()方法中以其他方式
    5. 或之前的其他方式:     mediaButton = new MediaButtonIntentReceiver();

      IntentFilter intentFilter = new IntentFilter(Intent.ACTION_MEDIA_BUTTON);
      intentFilter.setPriority(IntentFilter.SYSTEM_HIGH_PRIORITY-1);
      registerReceiver(mediaButton, intentFilter);
      
    6. 或者这个     ((AudioManager)getSystemService(AUDIO_SERVICE))。registerMediaButtonEventReceiver(new ComponentName(this,                 MediaButtonIntentReceiver.class));

      有什么建议吗?请帮忙。

1 个答案:

答案 0 :(得分:0)

我设法通过设置来部分破解:

<intent-filter>
<action android:name="android.intent.action.VOICE_COMMAND" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>

虽然我仍然不能为这个意图注册接收者&#34; android.intent.action.VOICE_COMMAND&#34;,但我不在其中。