BroadcastReceiver的register与unregister的timing问题
2016-02-10 15:01
363 查看
http://stackoverflow.com/questions/7887169/android-when-to-register-unregister-broadcast-receivers-created-in-an-activity
onDestroy() is not guaranteed to be called, and you could continue receiving broadcasts for a long time, when the Activity is no longer open.
所以,如只想在Activity在前台的时候接收Broadcast,那你就用
onDestroy() is not guaranteed to be called, and you could continue receiving broadcasts for a long time, when the Activity is no longer open.
onDestroy()并不能保证被调用,所以有这种可能:在
onDestroy()没有被调用的情况下(此时Activity并不在前台foreground),而你还在接收Broadcast,这可能不是你想要的。
所以,如只想在Activity在前台的时候接收Broadcast,那你就用
onResume() / onPause()
相关文章推荐
- [bzoj1030][JSOI2007]文本生成器
- 尼姆博弈+威佐夫博奕
- mysql获取上一步INSERT操作产生的ID
- cvMatchTemplate() 模板匹配
- USACO 1.5 sprime
- 在Linux信号处理中longjmp和siglongjmp
- [从头学数学] 第80节 数学广角──植树问题
- 海明码的生成
- java中static内存图解
- Android设计模式-单例模式
- 2016蓝桥杯算法训练——矩阵乘法
- Android 学习(2)
- Attaching the Filter Device Object to the Target Device Object
- 远征系列---离港篇(学杂记)
- OpenFoam--有限体积-计算流体力学-开源
- HDU 4725 The Shortest Path in Nya Graph(最短路)
- BNUOJ 51275 道路修建 Large(并查集)
- hdu 4081 Qin Shi Huang's National Road System 秦始皇的国家公路系统
- Hduoj1285【拓扑排序】
- ...