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

前端 未结 11 865
旧巷少年郎
旧巷少年郎 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:27

    @Override

    public void onDestroy() {
    
        Log.d(TAG, "onDestroy");
        super.onDestroy();
        if (mLocationManager != null) {
    
            for (int i = 0; i < mLocationListeners.length; i++) {
    
                try {
    
                    mLocationManager.removeUpdates(mLocationListeners[i]);
    
                } catch (Exception ex) {
    
                    Log.d(TAG, "fail to remove location listners, ignore", ex);
    
                }
    
            }
    
        }
    
    }
    

提交回复
热议问题