Service Automatic Called on Destroying Activity

后端 未结 4 937
天涯浪人
天涯浪人 2020-12-16 15:17

I am stuck with the problem of Activity + Service in that I have following number of Activities and Services.

Activities:

4条回答
  •  猫巷女王i
    2020-12-16 15:50

    (1)For Your Dialog:

    The solution is to call dismiss() on the Dialog you created before exiting the Activity, e.g. in onDestroy(). All Windows & Dialog should be closed before leaving an Activity.

    (2)For Your service autostart:

    you have to look at the value the service returns from its onStartCommand method. The default value is START_STICKY which will restart the service after it is destroyed. Take a look at the onStartCommand documentation for more details:

提交回复
热议问题