Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

[Android] Location service doesn't stop after closing app #9068

Closed
mpuchala opened this issue May 22, 2017 · 2 comments
Closed

[Android] Location service doesn't stop after closing app #9068

mpuchala opened this issue May 22, 2017 · 2 comments
Labels
Android Mapbox Maps SDK for Android

Comments

@mpuchala
Copy link

mpuchala commented May 22, 2017

Platform: Android 7.0
Mapbox SDK version: 5.1.0-SNAPSHOT (22.05)
Mapbox: 86e8108c4ffcb0ecbe279575cd80053a69629818
Lost: 55c1f2ba926d8db9c6738523432337104860da02

Steps to trigger behavior

  1. Open App
  2. Request Location
  3. Close App

Expected behavior

Stop Location Service

Actual behavior

Location Service is still working

Hey,

There is new problem with Location Service. Actually it exactly looks like one of my issues: #8683

It's probably (only my conjecture) related to changes in Lost library: #8999

It's quite easy to reproduce it - basic example:

public class MainActivity extends Activity implements OnMapReadyCallback {
    @Bind(R.id.map_view)
    MapView mMapView;

    private MapboxMap mMapboxMap;

    @OnClick(R.id.btn_enable)
    void onClickEnable() {
        mMapboxMap.setMyLocationEnabled(true);
    }

    @OnClick(R.id.btn_disable)
    void onClickDisable() {
        mMapboxMap.setMyLocationEnabled(false);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main_activity);
        ButterKnife.bind(this);

        mMapView.onCreate(savedInstanceState);
        mMapView.getMapAsync(this);
    }

    @Override
    public void onMapReady(MapboxMap mapboxMap) {
        mMapboxMap = mapboxMap;
    }

    @Override
    protected void onStart() {
        super.onStart();
        mMapView.onStart();
    }

    @Override
    protected void onResume() {
        super.onResume();
        mMapView.onResume();
    }

    @Override
    protected void onPause() {
        super.onPause();
        mMapView.onPause();
    }

    @Override
    protected void onSaveInstanceState(Bundle outState) {
        super.onSaveInstanceState(outState);
        mMapView.onSaveInstanceState(outState);
    }

    @Override
    public void onLowMemory() {
        super.onLowMemory();
        mMapView.onLowMemory();
    }

    @Override
    protected void onStop() {
        super.onStop();
        mMapView.onStop();
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        mMapView.onDestroy();
    }
}

If you don't enable location - it's not requested and there is no problem at all.
When you enable it once after closing the app problem occurs (even when you disable it before exit).

CC: @Guardiola31337 @tobrun @sarahlensing

@mrfaa
Copy link

mrfaa commented May 24, 2017

Hi there, I can confirm that in the newest com.mapbox.mapboxsdk:mapbox-android-sdk:5.1.0-SNAPSHOT@aar this issue appears again. Thanks a lot for working on this great project!

@zugaldia
Copy link
Member

@tobrun good to close after merging #9099?

@tobrun tobrun closed this as completed May 24, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Android Mapbox Maps SDK for Android
Projects
None yet
Development

No branches or pull requests

4 participants