2013-07-19 64 views
0

嗨大家好, 我正在开发一个android应用程序相关的俱乐部based.In.In我开始我的项目与建立目标(谷歌api),最后我完成了我的应用程序。客户端是他需要在该应用程序的地图。经过非常深入的分析,我发现谷歌更新谷歌地图版本变成1.2.To使用,我们可以设置建立的目标(Android 4.2)only.So现在我不知道做这..任何人都可以为我建议如何在我的应用程序中实现谷歌地图与建立目标谷歌API或者如何改变我的目标到Android 4.2 ??????谷歌地图不显示在我的应用程序

+0

使用google map api v2通过使用片段 – Nas

+0

[看到这个答案m aybe帮你] [1] [1]:http://stackoverflow.com/questions/17741100/google-api-map-v2-not-displaying-with-signed-apk-in-device/17741138#17741138 –

回答

0
//Add the follwing to your manifest 
<uses-sdk 
     android:minSdkVersion="12" 
     android:targetSdkVersion="17" /> 

    <permission 
     android:name="yourpackagename.permission.MAPS_RECEIVE" 
     android:protectionLevel="signature" /> 

    <uses-feature 
     android:glEsVersion="0x00020000" 
     android:required="true" /> 

    <uses-permission android:name="yourpackagename.permission.MAPS_RECEIVE" /> 
    <uses-permission android:name="android.permission.INTERNET" /> 
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> 
    <uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" /> 
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> 
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> 


//add this following to your manifest below the activity tag 

<meta-data 
      android:name="com.google.android.maps.v2.API_KEY" 
      android:value="your_apikey" /> 

//你的活动应该是这样的

@Override 
    protected void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.activity_main); 
    GoogleMap map = ((MapFragment) getFragmentManager().findFragmentById(R.id.yourmapid)) 
     .getMap(); 

    } 

//你的XML应该是这样的

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    tools:context=".MainActivity" > 

    <fragment 
     android:id="@+id/map" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     class="com.google.android.gms.maps.MapFragment" /> 

</RelativeLayout> 

注意:您必须导入fragmentactivity类,并添加谷歌,playservices- lib项目作为参考库

+0

deen谢谢你的建议..但它只会工作,如果我们设置一个内置的目标android4.2,但我的项目目标是谷歌API ..所以它只是显示瓷砖不是地图.... –

+0

你使用SHA键来生成地图API密钥? – Nas

+0

我只使用那个.. –