[android-developers] Re: How to detect when bluetooth is turned on by user?

2010-12-25 Thread martien huijsmans
Txs for the suggestion.
I implemented a BroadcastReceiver that listens for state changes
BluetoothAdapter.STATE_TURNING_OFF
and BluetoothAdapter.STATE_ON and stop or starts my Bluetooth service.
Everything works.

On Dec 24, 11:38 am, Indicator Veritatis mej1...@yahoo.com wrote:
 Please 
 readhttp://developer.android.com/reference/android/bluetooth/BluetoothAda...
 and notice that getDefaultAdapter() returns a real Adapter only if
 Bluetooth support exists. If Bluetooth support exists, but is turned
 off, then getState() returns STATE_OFF.

 At least that is the way it is supposed to work: I have vague memories
 of getDefaultAdapter() returning null when the adapter was turned off
 on my T-mobile G2. But I can't vouch for that, and am not taking out
 the time to test for it now.

 There is a broadcast action you can wait for: ACTION_STATE_CHANGED.
 Wait for this and then check to see what it changed to: on or off.

 On Dec 23, 11:15 am, martien huijsmans martien.huijsm...@gmail.com
 wrote:

  Hi,

  I have a implemented a Android service which start a Bluetooth server.
  This is based on the example Connecting as a server as found 
  onhttp://developer.android.com/guide/topics/wireless/bluetooth.html.

  How can I detect if Bluetooth if is turned on by the user?
  Is there a notification in Adroid that my service can subscribe to?
  In my current implementation I periodically poll the BluetoothAdapter
  as shown below
  itsBTAdapter.isEnabled().

  Regards Martien

-- 
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


[android-developers] How to detect when bluetooth is turned on by user?

2010-12-23 Thread martien huijsmans
Hi,

I have a implemented a Android service which start a Bluetooth server.
This is based on the example Connecting as a server as found on
http://developer.android.com/guide/topics/wireless/bluetooth.html.

How can I detect if Bluetooth if is turned on by the user?
Is there a notification in Adroid that my service can subscribe to?
In my current implementation I periodically poll the BluetoothAdapter
as shown below
itsBTAdapter.isEnabled().

Regards Martien

-- 
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