Android 2.3.3服务应用程序运行清晰,但在3.2 galaxy选项卡上,它确实有效,但被强制关闭



我在Sonny Erricson Xperia Ray 2.3 Android上运行以下服务,运行完美。 它旨在当用户尝试打开时自动禁用蓝牙和WiFi。

这将在引导上运行。

但是当我在 Galaxy 选项卡 10.2 android 3.2 上运行时,它适用于 wifi,但在蓝牙上它会强制关闭。

服务如下

IntentFilter filterb = new IntentFilter(BluetoothAdapter.ACTION_STATE_CHANGED);
BroadcastReceiver mReceiverb = new StatusReceiver();
registerReceiver(mReceiverb, filterb);

广播如下

BluetoothAdapter mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
if (mBluetoothAdapter.isEnabled()) {
    mBluetoothAdapter.disable();
}

许可如下

<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />

刚得到日志猫

E/AndroidRuntime( 9217): FATAL EXCEPTION: main
E/AndroidRuntime( 9217): java.lang.RuntimeException: Error receiving broadcast Intent { act=android.bluetooth.adapter.action.STATE_CHANGED flg=0x10000010 (has extras) } in google.android.disable.StatusReceiver@407bbc40
E/AndroidRuntime( 9217):    at android.app.LoadedApk$ReceiverDispatcher$Args.run(LoadedApk.java:734)
E/AndroidRuntime( 9217):    at android.os.Handler.handleCallback(Handler.java:587)
E/AndroidRuntime( 9217):    at android.os.Handler.dispatchMessage(Handler.java:92)
E/AndroidRuntime( 9217):    at android.os.Looper.loop(Looper.java:132)
E/AndroidRuntime( 9217):    at android.app.ActivityThread.main(ActivityThread.java:4126)
E/AndroidRuntime( 9217):    at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime( 9217):    at java.lang.reflect.Method.invoke(Method.java:491)
E/AndroidRuntime( 9217):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:844)
E/AndroidRuntime( 9217):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:602)
E/AndroidRuntime( 9217):    at dalvik.system.NativeStart.main(Native Method)
E/AndroidRuntime( 9217): Caused by: java.lang.SecurityException: Calling uid 10097 gave packageandroid which is owned by uid 1000
E/AndroidRuntime( 9217):    at android.os.Parcel.readException(Parcel.java:1321)
E/AndroidRuntime( 9217):    at android.os.Parcel.readException(Parcel.java:1275)
E/AndroidRuntime( 9217):    at android.bluetooth.IBluetooth$Stub$Proxy.disable(IBluetooth.java:806)
E/AndroidRuntime( 9217):    at android.bluetooth.BluetoothAdapter.disable(BluetoothAdapter.java:496)
E/AndroidRuntime( 9217):    at google.android.disable.StatusReceiver.onReceive(StatusReceiver.java:26)
E/AndroidRuntime( 9217):    at android.app.LoadedApk$ReceiverDispatcher$Args.run(LoadedApk.java:725)
E/AndroidRuntime( 9217):    ... 9 more

Android 参考指出,在没有明确用户操作的情况下,您不应调用 BluetoothAdapter.disable()。这意味着不应在设备启动时自动调用此方法。这可能是您错误的原因。

参考:http://developer.android.com/reference/android/bluetooth/BluetoothAdapter.html#disable()

相关内容

  • 没有找到相关文章

最新更新