Null Pointer Exception On Getlatitude
'double android.location.Location.getLatitude()' on a null object reference return new ParseGeoPoint(loc.getLatitude(), loc.getLongitude()); and with the ParseGeoQuery query.wher
Solution 1:
Add following another permission in your manifest
<uses-permissionandroid:name="android.permission.ACCESS_COARSE_LOCATION"/>
I know you are using ACCESS_FINE_LOCATION, but what if you lost GPS signal and try to get lat long. In this scenario you will get null data. To avoid such situation better to have another option to have location from Network Provider though it may not be accurate.
Make sure to connect your googleApiClient with this call after your client builder.
// Create a new location client, using the enclosing class to handle callbacks.
locationClient = new GoogleApiClient.Builder(this)
.addApi(LocationServices.API)
.addConnectionCallbacks(this)
.addOnConnectionFailedListener(this)
.build();
locationClient.connect();
Post a Comment for "Null Pointer Exception On Getlatitude"