0

i try to get bluetooth button key press with the popular code from the web. also in this thread Capture media button on Android >=4.0 (works on 2.3)

but google now responds to it (although my app is in foreground) cannot achieve this. what i did: (env nexus 4, android 4.4.4)

  1. turn off google now setting preferences 'bluetooth headset recording' (not sure the exact name cause i'm not using it in english - looks like a bug - it is off and still google search is responding

  2. turn off google now at all - i think it is another bug - it is off and still responds to to my BlueTooth button.

in my app:

  1. have correct BT permission

  2. in manifest file - register recevier by:

  3. or previous in other way in my app onCreate() method: mediaButton = new MediaButtonIntentReceiver();

    IntentFilter intentFilter = new IntentFilter(Intent.ACTION_MEDIA_BUTTON);
    intentFilter.setPriority(IntentFilter.SYSTEM_HIGH_PRIORITY-1);
    registerReceiver(mediaButton, intentFilter);
    

or this ((AudioManager)getSystemService(AUDIO_SERVICE)).registerMediaButtonEventReceiver(new ComponentName(this, MediaButtonIntentReceiver.class));

any suggestions? please help.

Community
  • 1
  • 1
vantropf
  • 25
  • 4

1 Answers1

0

I managed to partially hack this by setting:

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

although i cannot still register receiver for this intent "android.intent.action.VOICE_COMMAND", i do not undersand it.

vantropf
  • 25
  • 4