Я получаю исключение NullPointerException со следующим кодом:
private ProjectionProxy proxy = new ProjectionProxy();
private GoogleMap mMap = null;
private Context context = this;
@Override
protected void onCreate(Bundle load) {
super.onCreate(load);
setContentView(R.layout.fragment_ride_tracking);
//mMap = ((MapFragment) getFragmentManager().findFragmentById(R.id.myMapView)).getMap();
mMap = ((MapFragment) getFragmentManager().findFragmentById(R.id.map)).getMap();
int result = GooglePlayServicesUtil.isGooglePlayServicesAvailable(context);
mMap.setMapType(GoogleMap.MAP_TYPE_NORMAL);
mMap.setMyLocationEnabled(true);
//SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.myMapView);
//mMap = mapFragment.getMap();
Log.e("RideTracking", "Google Map VALUE:"+mMap);
if (mMap != null) {
proxy.setProjection(mMap.getProjection());
}
Строка, в которой происходит исключение NullPointerException, — это строка кода:
mMap = ((MapFragment) getFragmentManager().findFragmentById(R.id.map)).getMap();
Я не инициализирую свою переменную mMap значением null. В чем здесь моя проблема?
mMap = ((SupportMapFragment)(getSupportFragmentManager().findFragmentById(R.id.map))).getMap();
- person Pragnani   schedule 16.05.2013