I want to do something after the phone is in the charger. So I created ChargingOnReciever :
public class ChargingOnReceiver extends BroadcastReceiver { public void onReceive(Context context, Intent intent) { context.startActivity(someActivity); Log.d(TAG, "Phone was connected to power"); } }
and I want my receiver to listen for android.intent.action.ACTION_POWER_CONNECTED , so I injected this into the manifest:
<reciever android:name=".ChargingOnReceiver" android:enabled="true" android:exported="true"> <intent-filter> <action android:name="android.intent.action.ACTION_POWER_CONNECTED" /> </intent-filter> </reciever>
But ChargingOnReceiver does not seem to start when I install my G1 in the charger (connect to the laptop via the USB cable). Any help is much appreciated.
android android-intent
fhucho
source share