BroadcastReceiver: nie można utworzyć instancji klasy; brak pustego konstruktora
Mam klasę wewnętrzną jako odbiornik transmisji:
<code>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()); } }; </code>
AndroidManifest:
<code><receiver android:name=".statusbar.powerwidget.PowerWidgetGrid$ManualBacklightReceiver"> <intent-filter> <action android:name="com.android.systemui.statusbar.powerwidget.MANUAL_BACKLIGHT"/> </intent-filter> </receiver> </code>
A kiedy wyślę intencję za pomocą tego kodu: Intent intent = new Intent ();
<code>intent.setAction("com.android.systemui.statusbar.powerwidget.MANUAL_BACKLIGHT"); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); mContext.sendBroadcast(intent); </code>
Dostaję te wyjątki:
<code>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 </code>
Ale mam pustego konstruktora! Dlaczego to nie działa?