Android: How to safely unbind a service

后端 未结 8 953
深忆病人
深忆病人 2020-12-12 16:44

I have a service which is binded to application context like this:

getApplicationContext().bindService(
                    new Intent(this, ServiceUI.class         


        
8条回答
  •  忘掉有多难
    2020-12-12 16:51

    Use a variable to record if you have ever bind to a service, and unbind it if the variable is true.

    See android official example :

    http://androidxref.com/9.0.0_r3/xref/development/samples/ApiDemos/src/com/example/android/apis/app/RemoteService.java#376

提交回复
热议问题