java - Google Map variable is null -


i'm trying , set googlemap variable using the following code:

 private googlemap mmap;    mmap = ((mapfragment) getfragmentmanager().findfragmentbyid(r.id.mymapview)).getmap();      //mapfragment fm = (mapfragment)     getfragmentmanager().findfragmentbyid(r.id.mymapview);     //mmap = fm.getmap();      log.e("ridetracking", "google map value:"+mmap);      if (mmap != null) {          proxy.setprojection(mmap.getprojection());     } 

here xml part of app:

<fragment        android:id="@+id/mymapview"       android:layout_width="match_parent"       android:layout_height="match_parent"       android:name="com.google.android.gms.maps.mapfragment"/> 

for reason value of mmap null , i'm not sure why returning null since have line of code:

mmap = ((mapfragment) getfragmentmanager().findfragmentbyid(r.id.mymapview)).getmap(); 

here logcat output:

05-13 14:09:08.553: e/ridetracking(6415): google map value:null 

can offer advice on why of mmap null? appreciated.

if try putting code in method onactivitycreated(). make sure map ready.


Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -