This library simplified the way to get current location for user (lat,lng) it's based on google location library, with more option like request permissions for android 6 and above.
It easily get your current location by one line !
Maven
<dependency>
<groupId>net.salah.locate</groupId>
<artifactId>locate</artifactId>
<version>1.0.2</version>
<type>pom</type>
</dependency>
Gradle
dependencies {
compile 'net.salah.locate:locate:1.0.2'
}
make your activity or fragment class implements Locate.LocationResult
class MainActivity extends AppCompatActivity implements Locate.LocationResult
put this code where you need
Locate.with(MainActivity.this)
.addLocationResultListener(MainActivity.this)
.build();
and you get the result in overridden method 'onGetLocationSuccess(double lat, double lng)' or 'onGetLocationFailed(@Nullable String message)'
@Override
public void onGetLocationSuccess(double lat, double lng) {
((TextView)findViewById(R.id.result)).setText(getString(R.string.lat)+" : "+lat+"\n"+getString(R.string.lng)+" : "+lng);
}
@Override
public void onGetLocationFailed(@Nullable String message) {
((TextView)findViewById(R.id.result)).setText(message);
}
debuggingMode()
- for tracking and print all operation happened and library in android studio logcat not working to yet 😅
setPriority(Priority priority)
- used to set Priority for LocationRequest based on google location library more here
- LocationRequest
setInterval(long interval)
- used to set interval for LocationRequest based on google location library for example if you set it "60000" that means that you'll get updates every 60 seconds. more here
- LocationRequest
setFastInterval(long fastInterval)
- used to set fast interval for LocationRequest based on google location library more here
- LocationRequest