BroadcastReceiver里的context
2016-11-04 14:49
281 查看
官方文档对onReceive方法里context参数的解释是:The Context in which the receiver is running.
如果是静态注册的Broadcast,context.toString()输出为:android.app.ReceiverRestrictedContext@e5d8f65
如果是动态注册的Broadcast,context.toString()输出为:com.example.test.MainActivity@84dfef5
静态与动态注册的的Broadcast,context.getPackageName()输出都为:com.example.test
无论静态还是动态注册的Broadcast,都跑在广播所在app的进程。
如果是静态注册的Broadcast,context.toString()输出为:android.app.ReceiverRestrictedContext@e5d8f65
如果是动态注册的Broadcast,context.toString()输出为:com.example.test.MainActivity@84dfef5
静态与动态注册的的Broadcast,context.getPackageName()输出都为:com.example.test
无论静态还是动态注册的Broadcast,都跑在广播所在app的进程。
相关文章推荐
- BroadcastReceiver
- Android之Service与BroadCastReceiver
- 手机服务 & BroadcastReceiver & 获取电池相关内容
- android Service 服务(二)—— BroadcastReceiver
- android开发 - BroadcastReceiver 广播接收者
- 在Activity生命周期中注册BroadcastReceiver和在配置文件中注册的区别
- Android之BroadcastReceiver
- BroadcastReceiver详解
- 在Service或者BroadCastReceiver中弹出dialog
- 用广播(BroadcastReceiver)监听电池的变化
- Android四大组件之BroadcastReceiver
- 6.Android BroadcastReceiver
- 四大应用组件之BroadcastReceiver【Android】
- 四大组件Activity、Service、BroadcastReceiver、ContentProvider总结
- Android BroadcastReceiver详细介绍
- BroadcastReceiver ---Android中的广播机制(发短信)
- Service、BroadcastReceiver、Activity之间的通信
- Android四大组件之BroadcastReceiver
- 广播机制BroadCastReceiver
- BroadcastReceiver