Friday, September 30, 2016

Creating GPS App : Network Location Provider

friend in accessing location provider there is two location provider :
  • GPS Provider
  • Network Provider
now we will talk about Network Provider. before we begin we had to implement the permission in "AndroidManifest.xml" file.

and back to Network Provider.
 we have to create LocationManager and LocationListener and don't forget to check the permission.

LocationManager:
LocationManager locationManager = (LocationManager)getSystemService(Context.LOCATION_SERVICE);

Check the permission:
int permissionCheck = ContextCompat.checkSelfPermission(MapsActivity.this
Manifest.permission.ACCESS_FINE_LOCATION);

and to get the location we can access it by:
Location locationNet = locationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);

then we can access the Network Location Provider  Latitude and Longitude with

locationNet.getLatitude(); 
and

locationNet.getLongitude();

with double value type as return.

okay done for Location Provider with Network Provider

good luck friends. ^__^

"The biggest failure in life is to die without ever tried"


No comments:

Post a Comment