I am developing an application which requires to mark the current location of an user onto google maps. I have already got the code for setting up a marker on the current location.
private void handleNewLocation(Location location) {
Log.d(TAG, location.toString());
//get the new latitude and longitude
double currentLatitude = location.getLatitude();
double currentLongitude = location.getLongitude();
//create object to store them
LatLng latLng = new LatLng(currentLatitude, currentLongitude);
//create marker with the new position
MarkerOptions options = new MarkerOptions()
.position(latLng)
.title("I am here!");
//add marker to the map
mMap.addMarker(options);
//move camera to current location
mMap.moveCamera(CameraUpdateFactory.newLatLng(latLng));
}
There are no errors shown on compilation. But when running on emulator , it displays "MapActivity has stopped working".
I am using Nexus 5 API 21x86 android virtual device to run the app.
Please help !!!!!!!