My app should find the current location using GPS
,Cellular network
orWiFi
.I can easily find out the current location by GPS
LocationManager locationmanager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
LocationListener locationlistener = new mylocationlistener();
locationmanager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, locationlistener);
where mylocationlistener()
function is like below
private class mylocationlistener implements LocationListener {
@Override
public void onLocationChanged(Location location) {
if (location != null) {
Toast.makeText(LocationActivity.this,"latitude: "+
location.getLatitude() + "longitude: " + location.getLongitude(),
Toast.LENGTH_LONG).show();
}
}
It is working properly.I can use celluler network to find out the current location by the above code where i need to change locationmanager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0, locationlistener);
it is okey but my challenge is
- I need to find the GPS signal strength in order to activate GPS.If GPS signal strength is poor then i can't activate GPS because it will drain battery.
- If GPS signal is poor i have to find out the current location by cellular network or WiFi.
So,my question is that if there any way to determine the GPS signal strength without turning on GPS
?
Thank you advance for any kind of help.