市场更新后自动重新启动应用程序 [英] Auto-restart app after market update

查看:151
本文介绍了市场更新后自动重新启动应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

每当我发表我的市场应用程序的新版本,如果用户已经启用了自动更新选项,该应用程序会自动更新。

Anytime I publish a new version of my app in the Market, if the user had enabled the "auto update" option, the app will be updated automatically.

该应用程序包含了持续运行的服务。但是,当自动更新发生,旧的运行的应用程序被杀害,但不启动新的。 由于更新发生主要是透明的用户,这是有道理的,应用的服务应该这样,几乎没有中断的服务再次自动启动更新后。

The app contains a service that runs constantly. But when the automatic update happens, the old running app is killed, but the new one is not started. Since the update happens mostly transparently to the user, it makes sense that the app's service should be started again automatically after the update so that there is almost no interruption of the service.

这是一个有点难以从市场上真正的升级测试,所以我用下面的两个亚行命令来模拟这一更新过程。 安装的第一个版本:

It's a bit difficult to test this with a real update from the market, so I'm using the following two adb commands to simulate this update process. Install of the 1st version:

adb install oldversion.apk

自动更新:

adb install -r newversion.apk

在我运行第二个命令,应用程序被成功更新,但它已被停止并不会重新启动。

After I run the second command, the app gets successfully updated, but it has been stopped and not restarted.

如何才能使新版本的服务自动启动?

推荐答案

这件事情,你就必须仔细测试,但你应该能够用广播接收器与动作的 Intent.ACTION_PACKAGED_REPLACED

It's something you'll have to test carefully but you should be able to catch it with a broadcast receiver with the action Intent.ACTION_PACKAGED_REPLACED

然后你从你的接收器启动该服务。

Then you start the service from your receiver.

这篇关于市场更新后自动重新启动应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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