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

@mpuchala

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    AndroidMapbox Maps SDK for Android

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions