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

How to stop get location #9

Open
cahyofendhi opened this issue May 26, 2018 · 2 comments
Open

How to stop get location #9

cahyofendhi opened this issue May 26, 2018 · 2 comments

Comments

@cahyofendhi
Copy link

i have problem to stop get request location, after intent to another activity, request location still live, i have tried

disposable.dispose();

in destroy but not working,
how to solve this

@bluetoothfx
Copy link

Same issue here. Followed like sample application. Also have tried
compositeDisposable.dispose(); //may not needed
compositeDisposable.clear();

onDestry() is calling fine on activity destroy.
Problem is location sensor icon is not stopping showing.

Thanks,
Any idea is welcome.

@bluetoothfx
Copy link

bluetoothfx commented Jul 12, 2018

Followed the sample. Change the BaseActivity class like following. I have tested it. Please check and let me know if it works for you. Thanks.

package com.github.florent37.rxgps.sample;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;

import io.reactivex.disposables.CompositeDisposable;
import io.reactivex.disposables.Disposable;

public class BaseActivity extends AppCompatActivity {

private static CompositeDisposable compositeDisposable;

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    compositeDisposable = new CompositeDisposable();
}

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

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

public void addDisposable(Disposable disposable){
    this.compositeDisposable.add(disposable);
}

}

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants