快忙完了,陆续做一些工作上的回顾,一为分享,二为自己理清思路。

有缘看到这博文的朋友,如果在这上面有好的理解,我非常渴望可以得到你的指点^ ^

 

2.2不能使用restartPackage,这让任务管理器的开发者着实郁闷,一个用得这么普遍的功能说关就关了~有啥用意吗?google android framework team的工程师对这个的说明:

Actually it does exactly what it says -- it kills a process.  If an application has a service that it wants to keep running, the normal behavior of the system kicks in to restart the service for the app.  As the ocumentation says, this allows the app to do the same thing is the out of memory killer (killing processes) without breaking applications by causing their services to be stopped when they don't expect (or unregister their

alarms or the other things that fully stopping an app does).

 

restartPackage被太多的任务管理器所滥用,这个可以理解。比如,我们定义了一个定时器,但是随着restartPackage,定时器也会被关闭,而一般情况下,用户想关闭的仅仅是activity。以前在1.6上,launcher是shareduserid的(android:shareUserID = "android.uid.shared"),如果其他的应用程序A也具体这个属性,用restartPackage关闭A将导致launcher的重启,restartPackage会关掉于这个进程有关联的所有资源,是不是太“过”了?

 

使用killbackgroundprocesses ,alarms会被关掉,service会重启,如果是用户可见的activity,将不会被kill。不过,我暂时没发现用这个API有啥吸引人的地方,感觉不太好用。于是,为了在2.2里仍然保持以前restartPackage的效果,我使用了forceStopPackage。

 

posted on 2010-11-05 19:45  hhhaiya  阅读(2841)  评论(3编辑  收藏  举报