安卓:事件ACTION_POWER_CONNECTED不会被发送到我的BroadcastReceiver [英] Android: Event ACTION_POWER_CONNECTED is not sent to my BroadcastReceiver
问题描述
我想要做的事情后,电话被放入充电器。所以我 创建ChargingOnReciever:
I want to do something after the the phone is put into 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");
}
}
和我想我的接收器收听android.intent.action.ACTION_POWER_CONNECTED,所以我投入清单如下:
and I want my receiver to listen to android.intent.action.ACTION_POWER_CONNECTED, so I put this into 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>
但是,当我把我的G1到充电器ChargingOnReceiver显然未启动 (通过USB线连接到我的笔记本电脑)。任何帮助是非常AP preciated。
But ChargingOnReceiver is apparently not started when I put my G1 to charger (connect to my notebook via USB cable). Any help is much appreciated.
推荐答案
这是接收器,不reciever!我花了5小时找到这个愚蠢的错误。我认为Android的Eclipse插件应该做一些语法检查清单中的XML。
It's receiver, not reciever! It took me 5 hours to find this stupid bug. I think that the Android Eclipse plugin should do some syntax checking in the manifest xml.
这篇关于安卓:事件ACTION_POWER_CONNECTED不会被发送到我的BroadcastReceiver的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!