Wake an application after market update

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-08 06:07:40

问题


I would like my app to wake up after it has been updated using the market (play store). How can I accomplish that?

By waking up, I mean the Application.onCreate() to be executed.


回答1:


As Commonsware mentions, the ACTION_PACKAGE_REPLACED does the trick. You just need to compare your package name with the data for the intent, otherwise you catch all packages being replaced.

In newer API's (12 on up) there is the ACTION_MY_PACKAGE_REPLACED which is only sent to the application that was replaced.




回答2:


In principle, having a manifest-registered receiver for ACTION_PACKAGE_REPLACED should have this effect. Android should have to terminate your process to do the update, causing a fresh process to be created to deliver this broadcast to you.

That being said, I haven't tried this.



来源:https://stackoverflow.com/questions/13035244/wake-an-application-after-market-update

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!