yangwulin / backport-android-bluetooth

Automatically exported from code.google.com/p/backport-android-bluetooth
0 stars 0 forks source link

Cannot disable bluetooth #11

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
I was trying to turn bluetooth off,so I wrote this code:
BluetoothAdapter btAdapter = BluetoothAdapter.getDefaultAdapter();
btAdapter.disable();

But it doesn't work.Instead,it throws an error.

04-07 16:43:23.865: ERROR/AndroidRuntime(639): Caused by:
java.lang.reflect.UndeclaredThrowableException
04-07 16:43:23.865: ERROR/AndroidRuntime(639):     at
$Proxy0.disable(Native Method)
04-07 16:43:23.865: ERROR/AndroidRuntime(639):     at
backport.android.bluetooth.BluetoothAdapter.disable(BluetoothAdapter.java:312)
04-07 16:43:23.865: ERROR/AndroidRuntime(639):     at
com.warwithinme.android.widgetwar.ButtonBluetooth.toggleSetting(ButtonBluetooth.
java:51)
04-07 16:43:23.865: ERROR/AndroidRuntime(639):     at
com.warwithinme.android.widgetwar.ToggleWidget.onReceive(ToggleWidget.java:66)
04-07 16:43:23.865: ERROR/AndroidRuntime(639):     at
android.app.ActivityThread.handleReceiver(ActivityThread.java:2451)
04-07 16:43:23.865: ERROR/AndroidRuntime(639):     ... 10 more
04-07 16:43:23.865: ERROR/AndroidRuntime(639): Caused by:
java.lang.reflect.InvocationTargetException
04-07 16:43:23.865: ERROR/AndroidRuntime(639):     at
android.bluetooth.IBluetoothDevice$Stub$Proxy.disable(IBluetoothDevice.java:527)
04-07 16:43:23.865: ERROR/AndroidRuntime(639):     at
java.lang.reflect.Method.invokeNative(Native Method)
04-07 16:43:23.865: ERROR/AndroidRuntime(639):     at
java.lang.reflect.Method.invoke(Method.java:521)
04-07 16:43:23.865: ERROR/AndroidRuntime(639):     at
backport.android.bluetooth.DelegateFactory$InvocationHandlerImpl.invoke(Delegate
Factory.java:49)
04-07 16:43:23.865: ERROR/AndroidRuntime(639):     ... 15 more
04-07 16:43:23.865: ERROR/AndroidRuntime(639): Caused by:
java.lang.SecurityException: Cannot write secure settings table
04-07 16:43:23.865: ERROR/AndroidRuntime(639):     at
android.os.Parcel.readException(Parcel.java:1245)
04-07 16:43:23.865: ERROR/AndroidRuntime(639):     at
android.os.Parcel.readException(Parcel.java:1233)
04-07 16:43:23.865: ERROR/AndroidRuntime(639):     at
android.bluetooth.IBluetoothDevice$Stub$Proxy.disable(IBluetoothDevice.java:522)

Original issue reported on code.google.com by LiangM...@gmail.com on 7 Apr 2010 at 8:46