blog.csdn.net/ican87/article/details/21874321
www.cnblogs.com/pepcod/archive/2013/02/11/2937403.html
www.cnblogs.com/bravestarrhu/archive/2012/05/02/2479461.html
www.jianshu.com/p/51aaa65d5d25
1、Activity:
Activity生命周期,
super.onCreate(savedInstanceState)保存状态信息
onCreate: onStart:可见, onResume:可操作,onPause:有个对话框之类的挡住
onStop:完全挡住(可能后台被回收资源了) onDestroy:释放资源内存
系统配置发生改变导致activity被杀死并重新创建,比如说旋转屏幕(不配置Configuration情况下,第四个网址)
...-onPause-onSaveInstanceState-onStop...,...onStart-onRestoreInstanceState-onResume...
Android四种加载模式(Activity栈),每个启动模式的应用场景
Activity栈与Fragment栈的区别
上面第二个网址也有提到
http://blog.csdn.net/shinay/article/details/7898492
注意,例如主页经常设置为singleTask,singTop和singleTask模式会调用onNewIntent()方法
2、Service:(学了IPC后,重点关注bindService,binder机制)
概念:后台运行,无需界面,例子:音乐播放,后台记录地理位置
运行在主线程中,耗时操作要在子线程中实现
分为本地服务和远程服务(不熟)
两种启动方式
startService(),生命周期:onCreate--onStartCommand--onDestroy
onStartCommand可能有多次,其他只能一次
使用stopService服务才推出
bindService(),生命周期:onCreate--onBind--onUnbind--onDestroy
调用者推出服务即推出
http://www.cnblogs.com/pepcod/archive/2013/02/11/2937403.html
有什么特征,在哪种情况下会用到service
IntentService
http://blog.csdn.net/u011733020/article/details/45679587
AIDL(Android Interface Definition Language)(Android接口定义语言)(待解决)
IPC(Inter-Process Communication,进程间通信)(待解决)
如何避免service被杀掉(待解决)
Activity与Service交互(待解决)
http://www.cnblogs.com/pepcod/archive/2013/02/11/2937403.html
上面两个问题,这个网址有提到
3、Broadcast Receiver:
概念:用于接收广播Intent,
发送广播Intent是通过调用 Context.sendBroadcast(intent) 、
sendOrderedBroadcast(intent)、sendStickyBroadcast(intent) 来实现的。
分类:正常广播,有序广播,异步广播
生命周期:onRecieve(),超过10秒未处理完,ANR,有耗时操作一般会启动一个Service来完成
注册两种方式:静态,AndroidManifest.xml中,intent-filter中设置要接收的action
动态,代码里
onStart中注册,registerReceiver(BroadcastReceiver receiver, IntentFilter filter)
onDestroy中注销,unregisterReceiver(receiver);
两种注册方式区别
http://blog.csdn.net/u011733020/article/details/45679587
网友评论