手机充电后我想做些什么.所以我
创建了ChargingOnReciever:
创建了ChargingOnReciever:
public class ChargingOnReceiver extends BroadcastReceiver { public void onReceive(Context context,Intent intent) { context.startActivity(someActivity); Log.d(TAG,"Phone was connected to power"); } }
我希望我的接收器能够监听android.intent.action.ACTION_POWER_CONNECTED,所以我把它放到了清单中:
<reciever android:name=".ChargingOnReceiver" android:enabled="true" android:exported="true"> <intent-filter> <action android:name="android.intent.action.ACTION_POWER_CONNECTED" /> </intent-filter> </reciever>
但是当我把G1放到充电器上时,ChargingOnReceiver显然没有启动
(通过USB线连接到我的笔记本电脑).任何帮助深表感谢.