In my app I m trying to find the position from the device. My Code work s great:
boolean isGPSEnabled = locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER); boolean isNetworkEnabled = locationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER); if(isGPSEnabled || isNetworkEnabled) location = locationManager.getLastKnownLocation(isGPSEnabled ? LocationManager.GPS_PROVIDER : LocationManager.NETWORK_PROVIDER);
But after restart my device I don t get a location anymore. I tried it with another device. The code works, after restart I get null for my location... What is this?
Even after open google Maps, which found my position, I don t get the position...
Is it normal? Is there some workaround or something like this?
EDIT:
I don t use a LocationListener. I just use the code above in a asyntask for getting the position one time. I don t want to track the position the whole time