Skip to content
/ RxGps Public
forked from florent37/RxGps

Finding current location cannot be easier on Android !

License

Notifications You must be signed in to change notification settings

ersen-lw/RxGps

 
 

Repository files navigation

RxGps

Finding current location cannot be easier on Android !

- RxJava2 compatible

- Automatically ask for gps runtime permissions

- Check if play services are available for you ;)

Fork Changes

See Releases

https://github.com/ersen-lw/RxGps/releases

Download

Add the following to your project build.gralde file

  allprojects {
        repositories {
              maven {
                    url 'https://dl.bintray.com/erseno/RxGps'
              }
  }
}

Then add this dependency to your app build.gradle file.

  implementation "com.ersen:rxGps:1.1.1"

Usage

new RxGps(this).locationLowPower()

                .subscribeOn(Schedulers.newThread())
                .observeOn(AndroidSchedulers.mainThread())

                .subscribe(location -> {
                    //you've got the location
                }, throwable -> {
                    if (throwable instanceof RxGps.PermissionException) {
                        //the user does not allow the permission
                    } else if (throwable instanceof RxGps.PlayServicesNotAvailableException) {
                         //the user do not have play services
                    }
                });

GeoCoding

new RxGps(this).lastLocation()

                .flatMapMaybe(rxGps::geocoding)

                .subscribeOn(Schedulers.newThread())
                .observeOn(AndroidSchedulers.mainThread())

                .subscribe(address -> {
                    addressText.setText(getAddressText(address));
                }, throwable -> {
                    if (throwable instanceof RxGps.PermissionException) {
                        //the user does not allow the permission
                    } else if (throwable instanceof RxGps.PlayServicesNotAvailableException) {
                         //the user do not have play services
                    }
                });

Open Source

Forked from patloew RxLocation https://github.com/patloew/RxLocation

And use tbruyelle RxPermission https://github.com/tbruyelle/RxPermissions

Credits

Author: Florent Champigny http://www.florentchampigny.com/

Blog : http://www.tutos-android-france.com/

Fiches Plateau Moto : https://www.fiches-plateau-moto.fr/

Android app on Google Play Follow me on Google+ Follow me on Twitter Follow me on LinkedIn

License

Copyright 2016 florent37, Inc.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

About

Finding current location cannot be easier on Android !

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Java 100.0%