stopService doesn't stop's my service… why?

前端 未结 11 869
旧巷少年郎
旧巷少年郎 2020-12-03 07:02

i have a background service on my android APP that is getting my GPS position and sending it to a remote db. It work\'s fine.

The problem is when i want to stop the

11条回答
  •  眼角桃花
    2020-12-03 07:26

    If you are tracking GPS location, you probably used GoogleApiClient.

    The concept is that the Service WILL NOT stop,

    if an GoogleApiClient instance is still connected within it.

    (Or any other issue that need to be destroyed / unregistered first)

    So to make it works, implement onDestroy() within your service:

    @Override
    public void onDestroy()
    {
        // Unregistered or disconnect what you need to
        // For example: mGoogleApiClient.disconnect();
        super.onDestroy();
    }
    

提交回复
热议问题