Mam wewnętrzną klasę jako odbiornik nadanie:BroadcastReceiver: nie można utworzyć instancji klasy; nie pusty konstruktor
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>
I kiedy wysłać zamiar z tym kodem: Intent zamiarem = new Intent();
intent.setAction("com.android.systemui.statusbar.powerwidget.MANUAL_BACKLIGHT");
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
mContext.sendBroadcast(intent);
uzyskać te wyjątki:
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
Ale mam pusty konstruktor! Dlaczego to nie działa?
Czy próbowałeś zadzwonić do super(); wewnątrz twojego konstruktora? – Bobbake4
Ten sam błąd. – arts777