There is no way to turn on and off bluetooth through the official SDK right now.

Some apps have found ways to do this using hidden API's, and they are
going to break when cupcake is released.

Nick

On Wed, Feb 18, 2009 at 10:47 PM, Stanley.lei <[email protected]> wrote:
>
> Hi,
>
> I wanna write an app to enable and disable the Bluetooth device
> synchronized. Referring the Android source code, I registered
> following receiver to receive the bluetooth state change event:
>
> private static final String EXTENDED_BLUETOOTH_STATE_CHANGED_ACTION =
>
> "com.android.settings.bluetooth.intent.action.EXTENDED_BLUETOOTH_STATE_CHANGED";
>
>    private final BroadcastReceiver mReceiver = new BroadcastReceiver
> () {
>        @Override
>        public void onReceive(Context context, Intent intent) {
>            String action = intent.getAction();
>            if (action.equals
> (EXTENDED_BLUETOOTH_STATE_CHANGED_ACTION)) {
>                Log.d(LOG_TAG, "bt state changed");
>                ContentResolver resolver = context.getContentResolver
> ();
>
>                // If bluetooth is currently expected to be on, then
> enable or disable bluetooth
>                if (Settings.System.getInt(resolver,
> Settings.System.BLUETOOTH_ON, 0) > 0) {
>                    // do sth....
>                } else {
>                    // do sth...
>                }
>            }
>        }
>  };
>
>
> IntentFilter filter = new IntentFilter(
>                EXTENDED_BLUETOOTH_STATE_CHANGED_ACTION);
> registerReceiver(mReceiver, filter);
>
> But it doesn't work. Although the BT status has been changed (the icon
> of BT has been appeared or disappeared), the receiver could not
> receive nothing.
>
> Could you give me any suggestion on this issue? It is tearing out my
> hair.
>
> Any reply will be appreciated.
>
> Thanks,
>
> Stanley
> >
>

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

Reply via email to