What is the difference between START_STICKY and START_NOT_STICKY in the service?

Asked 1 years ago, Updated 1 years ago, 79 views

What is the difference between START_STICKY and START_NOT_STICKY in implementing services on Android?

android android-service

2022-09-22 13:13

1 Answers

: If the service is forced to shut down, the system restarts the service again, but restarts by initializing the int value to null. When you run the service, you call the startService (Intent service) method, and you can pass the value to the onStartCommand (Intent, int flags, int startId) method as int. Even if the value value of the int is previously set, the value of the int is initialized to null and restarted when the service is restarted.

: If you return this flag, the forced shutdown service will not restart. Even if it is forced to shut down by the system, you can use it when you are working on a serious task.

Additionally, there is START_REDELIVER_INTENT.

: As with START_STICKY, if the service is terminated, the system restarts the service, but keeps the int value intact. If you used Intent value when calling the startService() method, you can set the return value using the flag.


2022-09-22 13:13

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.