无法实例化接收器java.lang.IllegalAccessException:不允许访问类 [英] Unable to instantiate receiver, java.lang.IllegalAccessException: access to class not allowed
本文介绍了无法实例化接收器java.lang.IllegalAccessException:不允许访问类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在清单中,据我所知,我已经正确地声明了接收器元素. 但是当我发送广播时,接收方永远不会被呼叫.显示日志猫.
In the manifest I've declared the receiver element correctly to the best of my knowledge. But the Receiver never gets called when I send out the broadcast. The log cat shows.
07-22 23:51:49.181: E/AndroidRuntime(3799): FATAL EXCEPTION: main
07-22 23:51:49.181: E/AndroidRuntime(3799): java.lang.RuntimeException: Unable to instantiate receiver com.example.orderedbroadcastreceiver.HigherPriorityReceiver: java.lang.IllegalAccessException: access to class not allowed
07-22 23:51:49.181: E/AndroidRuntime(3799): at android.app.ActivityThread.handleReceiver(ActivityThread.java:2333)
07-22 23:51:49.181: E/AndroidRuntime(3799): at android.app.ActivityThread.access$1500(ActivityThread.java:139)
07-22 23:51:49.181: E/AndroidRuntime(3799): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1281)
07-22 23:51:49.181: E/AndroidRuntime(3799): at android.os.Handler.dispatchMessage(Handler.java:99)
07-22 23:51:49.181: E/AndroidRuntime(3799): at android.os.Looper.loop(Looper.java:137)
07-22 23:51:49.181: E/AndroidRuntime(3799): at android.app.ActivityThread.main(ActivityThread.java:4899)
07-22 23:51:49.181: E/AndroidRuntime(3799): at java.lang.reflect.Method.invokeNative(Native Method)
07-22 23:51:49.181: E/AndroidRuntime(3799): at java.lang.reflect.Method.invoke(Method.java:511)
07-22 23:51:49.181: E/AndroidRuntime(3799): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:791)
07-22 23:51:49.181: E/AndroidRuntime(3799): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:558)
07-22 23:51:49.181: E/AndroidRuntime(3799): at dalvik.system.NativeStart.main(Native Method)
07-22 23:51:49.181: E/AndroidRuntime(3799): Caused by: java.lang.IllegalAccessException: access to class not allowed
07-22 23:51:49.181: E/AndroidRuntime(3799): at java.lang.Class.newInstanceImpl(Native Method)
07-22 23:51:49.181: E/AndroidRuntime(3799): at java.lang.Class.newInstance(Class.java:1319)
07-22 23:51:49.181: E/AndroidRuntime(3799): at android.app.ActivityThread.handleReceiver(ActivityThread.java:2328)
07-22 23:51:49.181: E/AndroidRuntime(3799): ... 10 more
代码
class HigherPriorityReceiver extends BroadcastReceiver{
@Override
public void onReceive(Context context, Intent intent) {
Toast.makeText(context, "HigherPriorityReceiver", 0).show();
setResultCode(1985);
setResultData("DOB");
//abortBroadcast();
}
推荐答案
将类HigherPriorityReceiver
设置为public
类
这篇关于无法实例化接收器java.lang.IllegalAccessException:不允许访问类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文