Giter Site home page Giter Site logo

simplelocationgetter's Introduction

SimpleLocationGetter

Very simple way to get last known location.

This library is just a wrap on newly released Location API: https://android-developers.googleblog.com/2017/06/reduce-friction-with-new-location-apis.html

Getting started

This library will perfectly fit your existing build.gradle files:

//Project build.gradle
allprojects {
    repositories {
        jcenter()
        maven {
            url  "http://dl.bintray.com/skullper/maven"
        }
    }
}
//app(module) build.gradle
compile 'com.github.skullper:locationgetter:0.1'
compile 'com.google.android.gms:play-services-location:11.0.1'

Then you just need to add this two lines of code to get last known location:

SimpleLocationGetter getter = new SimpleLocationGetter(this, this);
getter.getLastLocation();

Oh, and don't forget to implement this awesome well written listener to class where the previous strings are declared:

implements SimpleLocationGetter.OnLocationGetListener
...
@Override
public void onLocationReady(Location location){
	Log.d("LOCATION", "onLocationReady: lat="+location.getLatitude() + " lon="+location.getLongitude());
}

@Override
public void onError(String error){
	Log.e("LOCATION", "Error: "+error);
}

As you probably see in onLocationReady() method you'll get your location and if API cannot get location or you just forgot to turn on your GPS you'll get a exact description in onError() method

And that's all folks!

Nope, also you need to check permissions by yourself. Sorry for this, but it's a SIMPLE location getter.

Good luck|have fun

simplelocationgetter's People

Contributors

skullper avatar

Watchers

Michael jentsch avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.