Simple map app on Android(google api v2). Doesnt work. Error

后端 未结 3 672
名媛妹妹
名媛妹妹 2021-01-23 01:17

I try to program an easy map app on Android but the only outcome are errors. I tried to program it the way it should be but it still doesn\'t work.

mainactivity<

3条回答
  •  青春惊慌失措
    2021-01-23 01:44

    Check my answer below :

    In your xml file change this class="com.google.android.gms.maps.MapFragment" to android:name="com.google.android.gms.maps.SupportMapFragment"

    Extend your activity to FragmentActivty and change

    map = ((MapFragment) getFragmentManager().findFragmentById(R.id.map)) .getMap(); to
    map= ((SupportMapFragment) getSupportFragmentManager() .findFragmentById(R.id.map)).getMap();
    

    Also check if (map== null) { map= ((SupportMapFragment) getSupportFragmentManager() .findFragmentById(R.id.map)).getMap();}

    Check your manifest file :

    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
        
            
                
    
                
            
        
    
        
        
        
    
    

    Hope this helps.

提交回复
热议问题