有没有办法升级Android上的应用程序后,重新启动服务? [英] Is there a way to restart a service after upgrading the application on Android?

查看:90
本文介绍了有没有办法升级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.

推荐答案

您说的没错,你应该使用的BroadcastReceiver

You are right that you should be using a BroadcastReceiver.

看一看<一href="http://stackoverflow.com/questions/2133986/how-to-know-my-android-application-has-been-upgraded-in-order-to-reset-an-alarm">this问题有关重新启动对升级报警;它展示了如何使用<一个href="http://developer.android.com/intl/fr/reference/android/content/Intent.html#ACTION_PACKAGE_REPLACED"><$c$c>ACTION_PACKAGE_REPLACED意图看,当一个应用程序的升级。

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.

这篇关于有没有办法升级Android上的应用程序后,重新启动服务?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆