Android的Activity启动长时间的操作开启一个Service比开启一个线程好
2011-07-05 00:53
561 查看
Because a process running a service is ranked higher than a process with background activities, an activity that initiates a long-running operation might do well to start a service for that operation, rather than simply create a worker thread—particularly if the operation will likely outlast the activity. For example, an activity that's uploading a picture to a web site should start a service to perform the upload so that the upload can continue in the background even if the user leaves the activity. Using a service guarantees that the operation will have at least "service process" priority, regardless of what happens to the activity. This is the same reason that broadcast receivers should employ services rather than simply put time-consuming operations in a thread.
Android的Activity启动长时间的操作开启一个Service比开启一个线程好,因为启动一个Service,他的进程级别为服务进程,优先级大于一个后台进程,被系统回收的概率低。
Android进程优先级:前台进程,可见进程,服务进程,后台进程,空进程。
Android的Activity启动长时间的操作开启一个Service比开启一个线程好,因为启动一个Service,他的进程级别为服务进程,优先级大于一个后台进程,被系统回收的概率低。
Android进程优先级:前台进程,可见进程,服务进程,后台进程,空进程。
相关文章推荐
- 在Activity中开启一个线程执行网络操作出现的问题
- 在android的service中启动一个通知,点击通知无法启动activity,报一个SecurityException异常
- android 中如何activity如何关闭一个开启自启动的service
- android service 启动和关闭不在同一个Activity的问题
- android从service里面启动一个Activity
- android 启动一个最简单的 activity 时的线程
- Activity、BroadcastReceiver、Service,只要是有长时间处理的任务,就需要重新开一个线程?!
- Android AsyncTask实现一个线程操作完成后启动另一个线程
- android adb 启动activity、service,发送broadcast等操作
- android之隐示意图--在一个 <intent-filter>意图中用两个action启动这个activity
- Android应用是否可以只有一个Service或Broadcast Reciver,而没有Activity?
- android之隐示意图--在一个 <intent-filter>意图中用两个category启动这个activity
- AMS—启动一个Activity(基于深入理解Android)
- Android中服务(Service)的的生命周期,两种开启服务的方式的不同点,Service与Activity之间的通讯
- Android开机启动Activity或者Service方法
- android service 通过broadcast通知Myreceiver 启动activity
- android 在Service中启动Activity
- Android中Activity、Service和线程之间的通信
- Android adb 发送广播、启动Activity、Service等
- Android中Activity、Service和线程之间的通信