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:
- while registering dynamically
registerReceiver
returnsnull
. - inside
Android monitor
window, i see log A2DP Playing state ..., meaning broadcast is sent. android.bluetooth.a2dp-sink.profile.action.PLAYING_STATE_CHANGED
is declared as<protected-broadcast>
in platform/frameworks/base/core/res/AndroidManifest.xml file
Any ideas, how to fix that ?
Thanks