简体   繁体   English

Google Play应用中的Android服务代码何时会更新?

[英]When Android Service code in a Google Play app will be updated?

I have an Android app published on Google Play. 我在Google Play上发布了一个Android应用。 When the app is launched for the first time (it is done by storing and checking boolean flag "FirstLaunch" in SharedPreferences ), it launches a Service which will be launched once a day (=every 24 hours using AlarmManager ). 首次启动该应用程序时(通过在SharedPreferences存储和检查布尔标志"FirstLaunch"来完成),它将启动一项Service ,该Service每天(一次使用AlarmManager每24小时启动一次)启动。
For the sake of simplicity let's say that this service just shows a Toast with "Hello World!" 为了简单起见,假设此服务仅显示带有"Hello World!"Toast "Hello World!" when the time comes. 在时机成熟时。

Let's assume that there is a user who downloaded and installed my app from Google Play. 假设有一个用户从Google Play下载并安装了我的应用。
Let's also assume that I have changed some code in that service (eg changed the Toast from "Hello World" to "Hello Universe!" ) and updated the app on Google Play. 我们还假设我已更改了该服务中的某些代码(例如,将Toast"Hello World"更改为"Hello Universe!" ),并在Google Play上更新了该应用程序。
If that user updates my app, will the service start showing new Toast text ( "Hello Universe" ) once a day, or will it still show the old version ( "Hello World" )? 如果该用户更新了我的应用,该服务将每天开始显示新的Toast文本( "Hello Universe" ),还是仍显示旧版本( "Hello World" )?

Generally speaking, if I am changing the code of a running service, do I need to relaunch it programmatically in my app, or will Android itselft change/switch its code to the new version? 一般来说,如果我要更改正在运行的服务的代码,是否需要在我的应用中以编程方式重新启动它,还是Android本身会更改/将其代码切换到新版本?

If Android updates an app (through the PlayStore of course),which you are currently using, it gets terminated. 如果Android(当然是通过PlayStore)更新了您当前正在使用的应用,则会终止该应用。 Services get terminated as well. 服务也会终止。 So if users of your app receive their update, their service gets terminated and restarted, if the startmode of your service is sticky or it gets restarted by your app. 所以,如果您的应用程序的用户收到他们的更新,他们的服务被终止,并重新启动,如果startmode为您服务的是sticky或它就会通过你的应用程序重新启动。

Android服务是您应用程序流程的一部分,在该流程终止时,您的服务也会终止(如果启动模式为粘性,则会重新启动整个流程)(因此它将重新启动),因此当用户更新应用程序时流程将以您的新代码开始

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

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