I have two issues, the first is that I have a String Builder that obtains an address and prints it to a edittext:
Geocoder mGC = new Geocoder(context,Locale.getDefault());
address = mGC.getFromLocation(lat, lng, 1);
if (address !=null){
Address currentAddr = address.get(0);
mSB = new StringBuilder();
for (int i=0; i<currentAddr.getMaxAddressLineIndex(); i++){
mSB.append(currentAddr.getAddressLine(i)).append(", ");
}
outputText.setText(mSB.toString());
}
The problem is randomly the address = mGC.getFromLocation(lat, lng, 1); line returns a null pointer exception. Sometimes it works for days…then suddenly it has a null pointer exception; anyone know why?
Also my second issue is my GPS fix takes some time, I am using the GPS Satellite for it; is there a way I can use Network provided info first and then the GPS Satellite for a faster fix?
About your second issue:
You need to have two location listeners, one for network and the other one for GPS. Then you should use onLocationChanged on each listener to do your logic, in this case first use the network location, and once you get an update for the GPS one you use that one instead.