I want to develop an application in which, if i open the app, it will show current location of my device. I want to do it without using gps. I have write a code for it. But
I didn't find the LocationListener to be useful, but need to put it in anyway to prevent null pointers.
// Set the criteria of what to look for
criteria = new Criteria();
criteria.setAccuracy(Criteria.ACCURACY_FINE);
criteria.setPowerRequirement(Criteria.POWER_LOW);
// This will find the location of the device via your network, but give user option to use GPS if needed
String locationprovider = mlocManager.getBestProvider(criteria,
true);
mLoc = mlocManager.getLastKnownLocation(locationprovider);
if (mLocation != null)
{
String Text = "My current location is: " +
"Latitud = " + mLoc.getLatitude() +
"Longitud = " + mLoc.getLongitude();
} else
{
String Text = "No location found."
}