简体   繁体   English

如何在旧版Android OS中使用API​​ V2显示GoogleMap(使用地图片段的情况下使用iam)

[英]How to Display GoogleMap(iam using map fragment) using API V2 in older version of android OS

I am in a project where i want to display the location of vehicle in Google map. 我在一个项目中想要在Google地图中显示车辆的位置。 I am getting the latitude and longitude of the vehicles from a Json web service and no problem in Diplaying the marker and setting the location. 我从Json Web服务获取了车辆的纬度和经度,并且在显示标记和设置位置方面没有问题。

My problem is that application is working fine on ICE CREAM SAND WITCH AND Jelly Bean OS mobiles, when i try to put the application in Gingerbread OS it is getting force closed. 我的问题是,该应用程序在ICE CREAM SAND WITCH和Jelly Bean OS手机上运行良好,当我尝试将其放入Gingerbread OS时,它被强制关闭。

In my application i am using the Map Fragment, and API V2. 在我的应用程序中,我正在使用Map Fragment和API V2。 I have added the android-support v 13 jar file to my library. 我已将android-support v 13 jar文件添加到我的库中。

Here is my Manifest code. 这是我的清单代码。

enter code here

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="info.tekguc.umut.googlemapsmapsandroidv2"
android:versionCode="1"
android:versionName="1.0" >

<uses-sdk
    android:minSdkVersion="4"
    android:targetSdkVersion="19"
    />

    <permission 
    android:name="com.example.androidmapsv2.permission.MAPS_RECEIVE" 
    android:protectionLevel="signature"></permission>

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

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

<application
    android:allowBackup="true"
    android:icon="@drawable/goo"
    android:label="@string/app_name"
    android:theme="@style/Translucent" >
      <meta-data
        android:name="com.google.android.maps.v2.API_KEY"
        android:value="AIzaSyDXAFrfJnmvVqOJFQ4w5WPajngNoeZpDMI"/>
    <activity
        android:name="info.tekguc.umut.googlemapsmapsandroidv2.LoginActivity"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>

    </activity>
      <activity
        android:name="info.tekguc.umut.googlemapsmapsandroidv2.HelpActivity"
        android:label="@string/app_name" >

    </activity>
      <activity
        android:name="info.tekguc.umut.googlemapsmapsandroidv2.MainActivity"
        android:label="@string/app_name" >

    </activity>
</application>

</manifest>

Please any one help me how to run this application in older versions of android OS.. 请任何人帮助我如何在旧版Android OS中运行此应用程序。

Thanks in Advance. 提前致谢。

First replace com.example.androidmapsv2 with your packagename in manifest.xml 首先用manifest.xml中的包名称替换com.example.androidmapsv2

then 然后

use SupportMapFragment for <3.0 versions as fragment is available from API 11(3.0) 请使用SupportMapFragment for <3.0版本,因为可以从API 11(3.0)获得片段

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

and your Activity class should looks like this 并且您的Activity类应如下所示

public class SupportMapFragmentActivity extends FragmentActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_support_map_fragment);

    FragmentManager fmanager = getSupportFragmentManager();
    Fragment fragment = fmanager.findFragmentById(R.id.map);
    SupportMapFragment supportmapfragment = (SupportMapFragment)fragment;
    GoogleMap supportMap = supportmapfragment.getMap();

  }

}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM