1

Background :

Developing application to make android phone A2DP receiver.

BlueDroid stack supports A2DP sink, but it's disabled by default. Modified source code to enable A2DP. Android phone is seen as HeadsFree Device and is connectable.

Problem :

I can't hear sound.

Tried :

A2dpSinkStateMachine class is in charge of acting android as A2dpSink. One of the state is Connected, it has method broadcastAudioState, which is called when audio starts/stops streaming. (line 579)

broadcastAudioState sends broadcast with action BluetoothA2dpSink.ACTION_PLAYING_STATE_CHANGED (line 696) and writes log A2DP Playing state....))

Registered broadcast receiver

- tried via manifest.xml file

<receiver android:name=".PlayingStateChangeBroadcastReceiver">
   <intent-filter>
      <action android:name="android.bluetooth.a2dp.profile.action.PLAYING_STATE_CHANGED" />
   </intent-filter>
</receiver>

- dynamically too

Intent intent = 
  registerReceiver(mReceiver, new IntentFilter(BluetoothA2dp.ACTION_PLAYING_STATE_CHANGED));

- dynamically with permission

  Intent intent = 
       registerReceiver(
             mReceiver, 
             new IntentFilter(BluetoothA2dp.ACTION_PLAYING_STATE_CHANGED), 
            "android.permission.BLUETOOTH", 
             new Handler(Looper.getMainLooper()));

onReceive method is never called.

Additionally:

Any ideas, how to fix that ?

Thanks

Community
  • 1
  • 1
tchelidze
  • 8,050
  • 1
  • 29
  • 49
  • I am sorry to ask this, but did you make sure your app has BLUETOOTH permission in the manifest? It's a system exported broadcast so there should not be any further problem. – Olaia Mar 10 '17 at 22:16
  • @Olaia Yes, app has `BLUETOOTH` permission but with no luck – tchelidze Mar 11 '17 at 09:11

0 Answers0