I have a PC (where java program is running), Bluetooth dongle (which supports A2DP) and Android device (2.3.6, which also supports A2DP).
I want to:
It is true that Android phone are uniquely
A2DP source devices.
Sadly, your first case is impossible to realize if you decide to rely on the
A2DP profile for streaming audio, because Android does not implement the required callbacks supposed to be handling BlueZ's advertisings when a remote device wants to stream audio to your phone.
The second use case is possible, given that you have a bluetooth enabled PC and some awesome apps that will decode and route the sound from the Bluetooth stack to the speakers. I managed once to reproduce this use case using
Here is a working example showing how to manage the routing of the sound once a connected BT device begins to stream. Here is another one. They both take place on Linux and I never did this on Windows though.
For the sake of completeness, here is another SO answer written by me, giving details about how to implement
A2DP sink capabilities on Android.
Nothing forbids you to implement your own protocol for audio streaming via Bluetooth on an Android device, this will work, but as it will not be a standard, it will never comply with the system built-in Bluetooth profiles (A2DP, HFP ...).