Android : How to use mFusedLocationClient callback (resulting location) in current mainthread
问题 Following is my adapter for a RecyclerView where i need to update one of the TextView which shows distance of current location to another location . Now , to get the current location , i am using mFusedLocationClient.requestLocationUpdates(mFusedLocationRquest,mLocationCallback,null); If i am going with the below code and have just enabled gps in app with runtime permission , i face NPE on line : float distance = updatedLoc.distanceTo(des); App does not crash when i open with gps already