Google Map API v2 is not showing Map on device

后端 未结 6 865
一个人的身影
一个人的身影 2020-12-29 05:42

I am running sample code that is provided on Google Map Documentation for Google Map Api v2 (https://developers.google.com/maps/documentation/android/start#specify_settings_

6条回答
  •  猫巷女王i
    2020-12-29 06:23

    Use Fragment activity

    eg:

    public class Maps extends FragmentActivity {
        GoogleMap map;
        double lat;
        double lan;
        boolean flag = false;
    
        // private LocationManager lm;
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.mapptry);
    
            map = ((SupportMapFragment) getSupportFragmentManager()
                    .findFragmentById(R.id.map)).getMap();
                     }
      }
    

    Change ur map.xml to

    
    

    EDIT

    Got to do this also

    import android.support.v4.app.FragmentActivity;

    Before you do this Right click project->properties->buildpath->java build path -> libraries .. then click on add external jars

    the go to

    user\android-sdks\extras\android\support\v4

    and select android-support-v4.jar

    PS: Do all this provided your API key is correct . If you API key is wrong then also it shows only a white screen

提交回复
热议问题