static - Why does this static Receiver not respond to the ACTION_POWER_(DIS)CONNECTED Event?
问题描述
I want a STATIC Broadcast Receiver to get fired, whenever the Phone gets charged or not. In my Manifest.xml, i have written the following Entry:
<receiver
android:name=".Starter">
<intent-filter>
<action android:name="android.intent.action.ACTION_POWER_CONNECTED" />
<action android:name="android.intent.action.ACTION_POWER_DISCONNECTED" />
</intent-filter>
</receiver>
The Broadcast Receiver itself looks like this:
public class Starter extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
Toast.makeText(context, "blablabla", Toast.LENGTH_LONG).show();
}
}
When I register the Receiver programmatically, everything works fine, but I want the Receiver also to respond, when the Activity is not open, so I have to make a static Receiver. Thank you for your help!!!
解决方案
推荐阅读
- php - disqus 评论框未显示帖子
- javascript - EaselJS 图片缩放模糊
- sql - 多次加入后删除重复
- javascript - 在表或数组上使用 for 循环来组合相同类别的多个条目
- php - numfmt_format_currency 但没有美分
- python - 从 DBF 文件中提取字段名称和类型
- r - 加入数据集时如何删除重复观察
- com - Windows Store 应用程序中的 RunningObjectTable 访问
- c# - Xamarin Forms api 调用不返回包含在 json 字符串中的相关实体
- angular - 事件触发多次(多次)时的socket.io + angular2 +观察者多个状态(路由)