Unable to instantiate receiver


java.lang.RuntimeException: Unable to instantiate receiver com.example.mylibrary02.activity.UpdateAppActivity$MyReceiver: java.lang.InstantiationException: can't instantiate class com.example.mylibrary02.activity.UpdateAppActivity$MyReceiver; no empty constructor

出现这个问题的原因是,我是以内部类定义的MyReceiver类,需要声明为static:

public static class MyReceiver extends BroadcastReceiver {
...

这是AndroidManifest.xml中的注册配置:

<receiver android:name=".activity.UpdateAppTestActivity$MyReceiver">

    <intent-filter>
        <action android:name="android.intent.action.BOOT_COMPLETED">action>
        <action android:name="cn.uprogrammer.CUSTOM_INTENT">action>
    intent-filter>

receiver>


你可能感兴趣的:(Android)