Reputation: 2141
I want to "push" the intent Intent.ACTION_BATTERY_CHANGED
in a service in onStart
I tried this:
Intent batteryChanged = new Intent();
batteryChanged.setAction(Intent.ACTION_BATTERY_CHANGED);
startActivity(batteryChanged);
How can I update the widget when it starts?
Upvotes: 0
Views: 297
Reputation: 48871
You can't send that Intent
yourself (see the excerpt below from the docs explaining it is a system intent). If your app needs to know when the battery state has changed you should be using a BroadcastReceiver
to listen for when the system updates it.
public static final String ACTION_BATTERY_CHANGED
...
This is a protected intent that can only be sent by the system.
Constant Value: "android.intent.action.BATTERY_CHANGED"
Upvotes: 1