If you tried to enable GPS before, you'll find it a complex task and encounter many problems. One of these problems is ResolvableApiException
which you must handle in your onActivityResult(). As a result you'll spread your logic everywhere!
Using RxLocationSettingsRequest you just write few lines of code and all the work will be done for you!
LocationRequest locationRequest = new ...
new RxGps()
.enable(locationRequest, MainActivity.this) // FragmentActivity
.subscribe(isLocationRequested -> {
if (isLocationRequested){
// Location is now enabled and you can implement your logic of
// location safely
}
});
dependencies {
implementation 'com.sha.kamel:rx-location-settings-request:1.0.4@aar'
}
allprojects {
repositories {
maven { url "https://dl.bintray.com/shabankamel/android" }
}
}