I'm confused about how to get my location when clicking a button.
I was trying with my code below:
private void showMyLocation() {
FusedLocationProviderApi fusedLocationApi = LocationServices.FusedLocationApi;
Location location = fusedLocationApi.getLastLocation(googleApiClient);
LatLng latLng = new LatLng(location.getLatitude(), location.getLongitude());
CameraUpdate cameraUpdate = CameraUpdateFactory.newLatLng(latLng);
map.animateCamera(cameraUpdate);
}
and the result is a force close app. I can't read logcat , because logcat is gone when the app crashes.
Are there any suggestions?