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

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

Closed

Description

@mpuchala

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

Activity

  1. added
    Android
    on May 22, 2017
  2. added this to the android-v5.1.0 milestone on May 22, 2017
  3. mrfaa commented on May 24, 2017

    @mrfaa

    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!

  4. zugaldia commented on May 24, 2017

    @zugaldia
    Member

    @tobrun good to close after merging #9099?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Android

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions