我有内部类作为广播接收器:
public class ManualBacklightReceiver extends BroadcastReceiver {
public static final String ACTION_MANUAL_BACKLIGHT = "com.android.systemui.statusbar.powerwidget.MANUAL_BACKLIGHT";
public ManualBacklightReceiver() {
}
@Override
public void onReceive(Context context, Intent intent) {
Log.d("ManualBacklightReceiver", intent.getAction());
}
};
安卓清单:
<receiver android:name=".statusbar.powerwidget.PowerWidgetGrid$ManualBacklightReceiver">
<intent-filter>
<action android:name="com.android.systemui.statusbar.powerwidget.MANUAL_BACKLIGHT"/>
</intent-filter>
</receiver>
当我使用此代码发送意图时: Intent intent = new Intent();
intent.setAction("com.android.systemui.statusbar.powerwidget.MANUAL_BACKLIGHT");
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
mContext.sendBroadcast(intent);
我得到这些例外:
java.lang.RuntimeException: Unable to instantiate receiver com.android.systemui.statusbar.powerwidget.PowerWidgetGrid$ManualBacklightReceiver:
java.lang.InstantiationException: can't instantiate class com.android.systemui.statusbar.powerwidget.PowerWidgetGrid$ManualBacklightReceiver; no empty constructor
Caused by: java.lang.InstantiationException: can't instantiate class com.android.systemui.statusbar.powerwidget.PowerWidgetGrid$ManualBacklightReceiver; no empty constructor
但我有一个空的构造函数!为什么它不起作用?