Skip to content
This repository was archived by the owner on Jan 16, 2025. It is now read-only.

devta-D/DeviceLocationManager

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DeviceLocationManager

Get user location in a simple way

Gradle

Step 1. Add it in your root build.gradle at the end of repositories:

allprojects {
	repositories {
		...
		maven { url 'https://jitpack.io' }
	}
}

Step 2. Add the dependency

dependencies {
	implementation 'com.github.devta-D:DeviceLocationManager:1.0'
}	

Usage


###java

  DeviceLocationManager locationManager = new DeviceLocationManager(activityContext);
  locationManager.createLocationRequest();

CallBacks

To catch DeviceLocationManager events implement DeviceLocationManager.LocationCallBacks into your Activity as following:

AppCompatActivity implements DeviceLocationManager.LocationCallBacks{

    @Override
    public void onGpsNotAllowedByUser() {
        //this catches the event when user dis-allows the app to turn on GPS.
        //create a request here to get location using network:
        locationManager.createLocationRequestNetwork();
    }

    @Override
    public void onCurrentLocationFound(Location location) {
        //catches the user current location
    }

    @Override
    public void onLocationPermissionDenied() {
        //when location permissions are denied by user
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        //when user allows the app to turn on device GPS, the result will come here in this method,
          just redirect the result to location manager and it will return a location by parsing the response.
        locationManager.onActivityResult(requestCode, resultCode);
    }

Developed By

Divyanshu Tayal Follow me on LinkedIn

TecOrb Technologies

About

Get user location in a simple way

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages