本文介绍了安卓2.3.3服务应用程序明确runns但3.2的Galaxy Tab它的工作,但得到强制关闭的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对索尼XPERIA李宁公司雷2.3的Andr​​oid其runns完美运行下面的服务。它被设计为自动关闭蓝牙和WiFi当过用户尝试打开。

本上运行的引导。

但是,当我运行的Galaxy Tab 10.2上的Andr​​oid 3.2它适用于无线网络,但蓝牙它得到的力量关闭。

服务如下:

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

广播如下:

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

许可给出如下

 <使用-权限的Andr​​oid:名称=android.permission.BLUETOOTH_ADMIN/>
<使用-权限的Andr​​oid:名称=android.permission.BLUETOOTH/>
<使用-权限的Andr​​oid:名称=android.permission.RECEIVE_BOOT_COMPLETED/>
 

刚刚拿到的logcat

  E / AndroidRuntime(9217):致命异常:主要
E / AndroidRuntime(9217):java.lang.RuntimeException的:接收广播错误意向{行动= android.bluetooth.adapter.action.STATE_CHANGED FLG = 0x10000010(有群众演员)}在google.android.disable.StatusReceiver@407bbc40
E / AndroidRuntime(9217):在android.app.LoadedApk $ ReceiverDispatcher $ Args.run(LoadedApk.java:734)
E / AndroidRuntime(9217):在android.os.Handler.handleCallback(Handler.java:587)
E / AndroidRuntime(9217):在android.os.Handler.dispatchMessage(Handler.java:92)
E / AndroidRuntime(9217):在android.os.Looper.loop(Looper.java:132)
E / AndroidRuntime(9217):在android.app.ActivityThread.main(ActivityThread.java:4126)
E / AndroidRuntime(9217):在java.lang.reflect.Method.invokeNative(本机方法)
E / AndroidRuntime(9217):在java.lang.reflect.Method.invoke(Method.java:491)
E / AndroidRuntime(9217):在com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:844)
E / AndroidRuntime(9217):在com.android.internal.os.ZygoteInit.main(ZygoteInit.java:602)
E / AndroidRuntime(9217):在dalvik.system.NativeStart.main(本机方法)
E / AndroidRuntime(9217):由:java.lang.SecurityException异常:调用UID 10097给packageandroid这是由UID 1000拥有
E / AndroidRuntime(9217):在android.os.Parcel.readException(Parcel.java:1321)
E / AndroidRuntime(9217):在android.os.Parcel.readException(Parcel.java:1275)
E / AndroidRuntime(9217):在android.bluetooth.IBluetooth $存根$ Proxy.disable(IBluetooth.java:806)
E / AndroidRuntime(9217):在android.bluetooth.BluetoothAdapter.disable(BluetoothAdapter.java:496)
E / AndroidRuntime(9217):在google.android.disable.StatusReceiver.onReceive(StatusReceiver.java:26)
E / AndroidRuntime(9217):在android.app.LoadedApk $ ReceiverDispatcher $ Args.run(LoadedApk.java:725)
E / AndroidRuntime(9217):9 ...更多
 

解决方案

Android的基准状态,你不应该叫BluetoothAdapter.disable()没有明确的用户操作。这意味着你不应该自动调用此方法的设备启动时。这可能是你错误的原因。

参考:的()

i have the following service running on the sonny erricson xperia Ray 2.3 android which runns perfectly. it is designed to automatically disable bluetooth and WiFi when ever the user try to switch on.

this runs on the boot.

But when i runs on the Galaxy tab 10.2 android 3.2 it works for wifi but on bluetooth it gets force closed.

Service is as follows

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

Broadcast is as follows

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

permission is given as follows

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

just got the logcat

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
解决方案

The Android reference states that you should not call BluetoothAdapter.disable() without explicit user action. This means you should not call this method automatically when the device boots. This may be the reason for your error.

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

这篇关于安卓2.3.3服务应用程序明确runns但3.2的Galaxy Tab它的工作,但得到强制关闭的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-26 19:25