java - NullPointerException on Map Object -
I use eclipse and android sdk. I want to point to a location on the map, so I use this function when the user button:
public zero pinpoint-location (reference reference) {map = (SupportMapFragment) (( FragmentActivity) mContext) .getSupportFragmentManager () FindFragmentById (android.R.id.content)). (); Marker hamburg = map.addMarker (new marker option). Position (hamburg). Title ("hamburg")); Marker key = map Edmark (new marker option.) Business (KIEL) .title ("key"). Senapet ("Nail is cool"). Inon (bitmap descriptor Forum Resource (RDW.IC_Luncher)); // Zoom to 15 to move the camera immediately to Hamburg. Map.moveCamera (CameraUpdateFactory.newLatLongZoom (Hamburg, 15)); // zoom in, animate the camera Map.animateCamera (CameraUpdateFactory.zoomTo (10), 2000, tap); } But when I run the program in the emulator it is an accident and I get this error:
04-24 06: 16: 35.327: E / Android Random (4070): java.lang.NullPointerException 04-24 06: 16: 35.327: E / Android Time (4070): com.example.hach.Mhelper.pinpointlocation (Mhelper.java:59) 04- 24 06: 16: 35.327: E / AndroidRuntime (4070): at com.example.hach. Main activity $ placeholder fragment $ 1.onClick (MainActivity.java:90) This line is the first line of 59 function. Why is the muck empty?
Please check the XML in your id Are referenced in. The quote of the docs
The underlying map system is loading and in the underlying view, GoogleMap can be obtained only by using getMap () Automatically launches map system and view; However, you can not be guaranteed when it will be ready because it depends on the availability of Google Play services. If GoogleMap is not available, getMap () zero will return. See also the availability of Google Play services before launching the map object. Read
Check Google Play services @
Comments
Post a Comment