简体   繁体   English

在Android上升级应用程序后,有没有办法重新启动服务?

[英]Is there a way to restart a service after upgrading the application on Android?

After upgrading my application I would like the service to restart if it was running before. 升级我的应用程序后,我希望该服务在以前运行时重新启动。 Is there any way to do this? 有没有办法做到这一点? I didn't see any Broadcast Intents that I could register for in the manifest. 我没有看到任何我可以在清单中注册的广播意图。

You are right that you should be using a BroadcastReceiver . 你应该使用BroadcastReceiver

Have a look at this question about restarting Alarms on upgrade ; 看看有关在升级时重启警报的问题 ; it shows how you can use the ACTION_PACKAGE_REPLACED Intent to see when an application is upgraded. 它显示了如何使用ACTION_PACKAGE_REPLACED Intent查看应用程序何时升级。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM