I don't see an API for this, but if you can add your own BroadcastReceiver 
to listen for ACTION_ACL_DISCONNECTED, and ACTION_ACL_CONNECTED you can at 
least maintain your own list of connected devices, and keep track yourself 
of which was last connected at the (low) ACL level. It is a broadcast, 
after all, so you can register your own receiver for it without worrying 
about interfering with or interference from Android's own receiver(s) for 
the same Intent.

If that is too low level for you, then you will need a different procedure. 
If you have only IPC proxies you are concerned with, it is even easier (use 
BluetoothProfile.ServiceListener). But you did not even tell us whether 
your device is the BluetoothSocketServer or not, so I cannot describe any 
of these other procedures.

But you are right that  BluetoothAdapter.ACTION_STATE_CHANGED does not help 
you in this problem: that Intent is far too coarse, only telling you when 
the whole adapter's state has changed (e.g. on/off): connection of remote 
devices is not considered part of the whole adapter's state.

On Thursday, January 24, 2013 11:51:56 AM UTC-8, Stefan Strobel wrote:
>
> Hi Community,
>
> how do I get the last connected / paired bluetooth device when bluetooth 
> is being turned off?
> As far as I can see, I cannot access the last connected device listening 
> to the BluetoothAdapter.ACTION_STATE_CHANGED broadcast.
> Neither can I get something work with BluetoothAdapter.STATE_TURNING_OFF.
>
> How would I get device name and device address of the last connected 
> bluetooth device when bluetooth is turned off?
>
> Thanks!
>

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


Reply via email to