I have inner class as broadcast receiver:
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());
}
};
AndroidManifest:
<receiver android:name=".statusbar.powerwidget.PowerWidgetGrid$ManualBacklightReceiver">
<intent-filter>
<action android:name="com.android.systemui.statusbar.powerwidget.MANUAL_BACKLIGHT"/>
</intent-filter>
</receiver>
And when I send the intent with this code:
Intent intent = new Intent();
intent.setAction("com.android.systemui.statusbar.powerwidget.MANUAL_BACKLIGHT");
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
mContext.sendBroadcast(intent);
I get these exceptions:
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
But I have an empty constructor! Why it doesn't work?
question from:
https://stackoverflow.com/questions/10305261/broadcastreceiver-cant-instantiate-class-no-empty-constructor 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…