I'm new to Android programing, and am trying to use a map with my current location, but when I look at logcat, I see the following error:
RunTimeException android.content.res.Resources$NotFoundException: Resource ID #0x7f020278 at android.content.res.Resources.getValue(Resources.java:2329) at android.content.res.Resources.startRC(Resources.java:1057) at android.app.ActivityThread$mRunnable.run(ActivityThread.java:2477) at java.lang.Thread.run(Thread.java:818) 07-15 18:40:16.624 13526-13526 com.example.paul.mapasxavo E/ViewRootImpl﹕ sendUserActionEvent() mView == null
The Java code in the MapsActiviy class is:
public class MapsActivity extends FragmentActivity {
// Might be null if Google Play services APK is not available.
private GoogleMap mMap;
private SensorManager sensorManager;
private Sensor accelerometer;
LocationManager locationManager;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_maps);
setUpMapIfNeeded();
}
@Override
protected void onResume() {
super.onResume();
setUpMapIfNeeded();
}
private void setUpMap() {
LOCATION_SERVICE locationManager =
(LocationManager)getSystemService(LOCATION_SERVICE);
Criteria criteria = new Criteria();
String provider = locationManager.getBestProvider(criteria, true);
Location location = locationManager.getLastKnownLocation(provider);
mMap.clear();
LatLng currentPosition = new LatLng(location.getLatitude(), location.getLongitude());
mMap.addMarker(new MarkerOptions().position(currentPosition).title("Yo"));
mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(currentPosition, 13));
mMap.setMyLocationEnabled(true);
Log.v("MapaActivity", currentPosition.toString());
}
}
This is the XML File
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
android:layout_height="match_parent" android:id="@+id/map"
tools:context="com.example.paul.mapasxavo.MapsActivity"
android:name="com.google.android.gms.maps.SupportMapFragment" />
What am I doing wrong?