如何通过onClickListener启动一个MapActivity?

How to start a MapActivity through onClickListener?

我正在构建一个 android 应用程序,我需要使用一个按钮来启动地图 activity。我已经阅读了有关片段的所有内容,但似乎对我没有任何帮助。我是 android 应用程序开发的新手,也是 Whosebug 的新手。所以我需要帮助。我的主要 activity、地图 Activity 和地图布局文件如下。任何帮助将不胜感激。

主要Activity

package com.save.me;

import android.app.Activity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;import android.view.View.OnClickListener;

public class MainActivity extends Activity {

Button button;
Button button1;

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

    button = (Button) this.findViewById(R.id.button2);
    button.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            Intent i = new Intent(MainActivity.this, First_aid.class);
            startActivity(i);
        }
    });

    button1 = (Button) this.findViewById(R.id.button1);
    button1.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            Intent i = new Intent(MainActivity.this, GpsActivity.class);
            startActivity(i);
        }
    });

}
}

地图Activity文件

package com.save.me;

import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.MapFragment;

import android.app.Activity;
import android.os.Bundle;
import android.widget.Toast;

public class GpsActivity extends Activity {

// Google Map
private GoogleMap googleMap;

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

    try {
        // Loading map
        initilizeMap();

    } catch (Exception e) {
        e.printStackTrace();
    }

}

/**
 * function to load map. If map is not created it will create it for you
 * */
private void initilizeMap() {
    if (googleMap == null) {
        googleMap = ((MapFragment) getFragmentManager().findFragmentById(
                R.id.map)).getMap();

        // check if map is created successfully or not
        if (googleMap == null) {
            Toast.makeText(getApplicationContext(),
                    "Sorry! unable to create maps", Toast.LENGTH_SHORT)
                    .show();
        }
    }
}

@Override
protected void onResume() {
    super.onResume();
    initilizeMap();
}

}

地图布局文件

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >

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

</RelativeLayout>

清单

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.save.me"
android:versionCode="1"
android:versionName="1.0" >

<permission
    android:name="com.save.me.permission.MAPS_RECEIVE"
    android:protectionLevel="signature" />

<uses-permission android:name="com.save.me.permission.MAPS_RECEIVE" />

<uses-sdk
    android:minSdkVersion="11"
    android:targetSdkVersion="21" />

<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission     android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

<!-- Required to show current location -->
<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/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >
    <uses-library android:name="com.google.android.maps" />

    <activity
        android:name=".MainActivity"
        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=".First_aid"
        android:label="@string/title_activity_first_aid" >
    </activity>
    <activity
        android:name=".SliderActvity"
        android:label="@string/title_activity_slider_actvity" >
    </activity>
    <activity
        android:name=".GpsActivity"
        android:label="@string/title_activity_gps" >
        <category android:name="android.intent.category.LAUNCHER" />
    </activity>
    <activity
        android:name=".ListDisplay"
        android:label="@string/title_activity_list_display" >
    </activity>
    <activity
        android:name=".Listitem1"
        android:label="@string/title_activity_listitem1" >
    </activity>
    <activity
        android:name=".Listitem2"
        android:label="@string/title_activity_listitem2" >
    </activity>
    <activity
        android:name=".Listitem3"
        android:label="@string/title_activity_listitem3" >
    </activity>
    <activity
        android:name=".Listitem4"
        android:label="@string/title_activity_listitem4" >
    </activity>
    <activity
        android:name=".Listitem5"
        android:label="@string/title_activity_listitem5" >
    </activity>
    <activity
        android:name=".Listitem6"
        android:label="@string/title_activity_listitem6" >
    </activity>
    <activity
        android:name=".Listitem7"
        android:label="@string/title_activity_listitem7" >
    </activity>
    <activity
        android:name=".Listitem8"
        android:label="@string/title_activity_listitem8" >
    </activity>
    <activity
        android:name=".Listitem9"
        android:label="@string/title_activity_listitem9" >
    </activity>
    <activity
        android:name=".Listitem10"
        android:label="@string/title_activity_listitem10" >
    </activity>
    <activity
        android:name=".Dummy"
        android:label="@string/title_activity_dummy" >
    </activity>

    <!-- Google Maps API Key -->
    <meta-data
        android:name="com.google.android.maps.v2.API_KEY"
        android:value="*****I've included legitimate map API key*****" />
</application>

Logcat

  01-23 21:51:34.922: D/OpenGLRenderer(24057): prepareDirty (0.00, 0.00, 480.00, 800.00) opaque 1 <0x600d8ce0>
01-23 21:51:34.924: D/OpenGLRenderer(24057): finish <0x600d8ce0>
01-23 21:51:34.954: D/OpenGLRenderer(24057): prepareDirty (0.00, 0.00, 480.00, 800.00) opaque 1 <0x600d8ce0>
01-23 21:51:34.955: D/OpenGLRenderer(24057): finish <0x600d8ce0>
01-23 21:51:34.985: D/OpenGLRenderer(24057): prepareDirty (0.00, 0.00, 480.00, 800.00) opaque 1 <0x600d8ce0>
01-23 21:51:34.987: D/OpenGLRenderer(24057): finish <0x600d8ce0>
01-23 21:51:35.0    01: D/OpenGLRenderer(24057): prepareDirty (0.00, 0.00, 480.00, 800.00) opaque 1 <0x600d8ce0>
01-23 21:51:35.003: D/OpenGLRenderer(24057): finish <0x600d8ce0>
01-23 21:51:35.    017: D/OpenGLRenderer(24057): prepareDirty (0.00, 0.00, 480.00, 800.00) opaque 1 <0x600d8ce0>
01-23 21:51:35.    019: D/OpenGLRenderer(24057): finish <0x600d8ce0>
01-23 21:51:35.033: D/OpenGLRenderer(24057): prepareDirty (0.00, 0.00, 480.00, 800.00) opaque 1 <0x600d8ce0>
01-23 21:51:35.035: D/OpenGLRenderer(24057): finish <0x600d8ce0>
01-23 21:51:35.049: D/OpenGLRenderer(24057): prepareDirty (0.00, 0.00, 480.00, 800.00) opaque 1 <0x600d8ce0>
01-23 21:51:35.051: D/OpenGLRenderer(24057): finish <0x600d8ce0>
01-23 21:51:35.065: D/OpenGLRenderer(24057): prepareDirty (0.00, 0.00, 480.00, 800.00) opaque 1 <0x600d8ce0>
01-23 21:51:35.067: D/OpenGLRenderer(24057): finish <0x600d8ce0>
01-23 21:51:35.080: D/OpenGLRenderer(24057): prepareDirty (0.00, 0.00, 480.00, 800.00) opaque 1 <0x600d8ce0>
01-23 21:51:35.082: D/OpenGLRenderer(24057): finish <0x600d8ce0>
01-23 21:51:35.096: D/OpenGLRenderer(24057): prepareDirty (0.00, 0.00, 480.00, 800.00) opaque 1 <0x600d8ce0>
01-23 21:51:35.098: D/OpenGLRenderer(24057): finish <0x600d8ce0>
01-23 21:51:35.121: D/OpenGLRenderer(24057): prepareDirty (0.00, 0.00, 480.00, 800.00) opaque 1 <0x600d8ce0>
01-23 21:51:35.123: D/OpenGLRenderer(24057): finish <0x600d8ce0>
01-23 21:51:35.144: D/OpenGLRenderer(24057): prepareDirty (0.00, 0.00, 480.00, 800.00) opaque 1 <0x600d8ce0>
01-23 21:51:35.146: D/OpenGLRenderer(24057): finish <0x600d8ce0>
01-23 21:51:35.159: D/OpenGLRenderer(24057): prepareDirty (0.00, 0.00, 480.00, 800.00) opaque 1 <0x600d8ce0>
01-23 21:51:35.161: D/OpenGLRenderer(24057): finish <0x600d8ce0>
01-23 21:51:35.175: D/OpenGLRenderer(24057): prepareDirty (0.00, 0.00, 480.00, 800.00) opaque 1 <0x600d8ce0>
01-23 21:51:35.177: D/OpenGLRenderer(24057): finish <0x600d8ce0>
01-23 21:51:35.191: D/OpenGLRenderer(24057): prepareDirty (0.00, 0.00, 480.00, 800.00) opaque 1 <0x600d8ce0>
01-23 21:51:35.193: D/OpenGLRenderer(24057): finish <0x600d8ce0>
01-23 21:51:35.207: D/OpenGLRenderer(24057): prepareDirty (0.00, 0.00, 480.00, 800.00) opaque 1 <0x600d8ce0>
01-23 21:51:35.208: D/OpenGLRenderer(24057): finish <0x600d8ce0>
01-23 21:51:35.222: D/OpenGLRenderer(24057): prepareDirty (0.00, 0.00, 480.00, 800.00) opaque 1 <0x600d8ce0>
01-23 21:51:35.224: D/OpenGLRenderer(24057): finish <0x600d8ce0>
01-23 21:51:35.238: D/OpenGLRenderer(24057): prepareDirty (0.00, 0.00, 480.00, 800.00) opaque 1 <0x600d8ce0>
01-23 21:51:35.240: D/OpenGLRenderer(24057): finish <0x600d8ce0>
01-23 21:51:35.254: D/OpenGLRenderer(24057): prepareDirty (0.00, 0.00, 480.00, 800.00) opaque 1 <0x600d8ce0>
01-23 21:51:35.256: D/OpenGLRenderer(24057): finish <0x600d8ce0>
01-23 21:51:35.270: D/OpenGLRenderer(24057): prepareDirty (0.00, 0.00, 480.00, 800.00) opaque 1 <0x600d8ce0>
01-23 21:51:35.272: D/OpenGLRenderer(24057): finish <0x600d8ce0>
01-23 21:51:35.286: D/OpenGLRenderer(24057): prepareDirty (0.00, 0.00, 480.00, 800.00) opaque 1 <0x600d8ce0>
01-23 21:51:35.288: D/OpenGLRenderer(24057): finish <0x600d8ce0>
01-23 21:51:35.3    01: D/OpenGLRenderer(24057): prepareDirty (0.00, 0.00, 480.00, 800.00) opaque 1 <0x600d8ce0>
01-23 21:51:35.303: D/OpenGLRenderer(24057): finish <0x600d8ce0>
01-23 21:51:35.317: I/BufferQueue(24057): [unnamed-24057-3](this:0x6005a538,id:3,api:1,p:24057,c:24057) [release] fps:58.38, dur:1    010.67, max:31.86, min:14.27
01-23 21:51:35.317: D/OpenGLRenderer(24057): prepareDirty (0.00, 0.00, 480.00, 800.00) opaque 1 <0x600d8ce0>
01-23 21:51:35.319: D/OpenGLRenderer(24057): finish <0x600d8ce0>
01-23 21:51:35.341: D/OpenGLRenderer(24057): prepareDirty (0.00, 0.00, 480.00, 800.00) opaque 1 <0x600d8ce0>
01-23 21:51:35.344: D/OpenGLRenderer(24057): finish <0x600d8ce0>
01-23 21:51:35.364: D/OpenGLRenderer(24057): prepareDirty (0.00, 0.00, 480.00, 800.00) opaque 1 <0x600d8ce0>
01-23 21:51:35.366: D/OpenGLRenderer(24057): finish <0x600d8ce0>
01-23 21:51:35.380: D/OpenGLRenderer(24057): prepareDirty (0.00, 0.00, 480.00, 800.00) opaque 1 <0x600d8ce0>
01-23 21:51:35.382: D/OpenGLRenderer(24057): finish <0x600d8ce0>
01-23 21:51:35.397: D/OpenGLRenderer(24057): prepareDirty (0.00, 0.00, 480.00, 800.00) opaque 1 <0x600d8ce0>
01-23 21:51:35.398: D/OpenGLRenderer(24057): finish <0x600d8ce0>
01-23 21:51:35.412: D/OpenGLRenderer(24057): prepareDirty (0.00, 0.00, 480.00, 800.00) opaque 1 <0x600d8ce0>
01-23 21:51:35.413: D/OpenGLRenderer(24057): finish <0x600d8ce0>
01-23 21:51:35.421: I/BufferQueue(24057): [unnamed-24057-3](this:0x6005a538,id:3,api:1,p:24057,c:24057) [queue] fps:61.95, dur:1000.80, max:19.51, min:12.11
01-23 21:51:35.428: D/OpenGLRenderer(24057): prepareDirty (0.00, 0.00, 480.00, 800.00) opaque 1 <0x600d8ce0>
01-23 21:51:35.430: D/OpenGLRenderer(24057): finish <0x600d8ce0>
01-23 21:51:35.443: D/OpenGLRenderer(24057): prepareDirty (0.00, 0.00, 480.00, 800.00) opaque 1 <0x600d8ce0>
01-23 21:51:35.445: D/OpenGLRenderer(24057): finish <0x600d8ce0>
01-23 21:51:35.460: D/OpenGLRenderer(24057): prepareDirty (0.00, 0.00, 480.00, 800.00) opaque 1 <0x600d8ce0>
01-23 21:51:35.461: D/OpenGLRenderer(24057): finish <0x600d8ce0>
01-23 21:51:35.475: D/OpenGLRenderer(24057): prepareDirty (0.00, 0.00, 480.00, 800.00) opaque 1 <0x600d8ce0>
01-23 21:51:35.477: D/OpenGLRenderer(24057): finish <0x600d8ce0>
01-23 21:51:35.491: D/OpenGLRenderer(24057): prepareDirty (0.00, 0.00, 480.00, 800.00) opaque 1 <0x600d8ce0>
01-23 21:51:35.492: D/OpenGLRenderer(24057): finish <0x600d8ce0>
01-23 21:51:35.507: D/OpenGLRenderer(24057): prepareDirty (0.00, 0.00, 480.00, 800.00) opaque 1 <0x600d8ce0>
01-23 21:51:35.508: D/OpenGLRenderer(24057): finish <0x600d8ce0>
01-23 21:51:35.522: D/OpenGLRenderer(24057): prepareDirty (0.00, 0.00, 480.00, 800.00) opaque 1 <0x600d8ce0>
01-23 21:51:35.524: D/OpenGLRenderer(24057): finish <0x600d8ce0>
01-23 21:51:35.538: D/OpenGLRenderer(24057): prepareDirty (0.00, 0.00, 480.00, 800.00) opaque 1 <0x600d8ce0>
01-23 21:51:35.540: D/OpenGLRenderer(24057): finish <0x600d8ce0>
01-23 21:51:35.570: D/OpenGLRenderer(24057): prepareDirty (0.00, 0.00, 480.00, 800.00) opaque 1 <0x600d8ce0>
01-23 21:51:35.571: D/OpenGLRenderer(24057): finish <0x600d8ce0>
01-23 21:51:35.6    01: D/OpenGLRenderer(24057): prepareDirty (0.00, 0.00, 480.00, 800.00) opaque 1 <0x600d8ce0>
01-23 21:51:35.603: D/OpenGLRenderer(24057): finish <0x600d8ce0>
01-23 21:51:35.633: D/OpenGLRenderer(24057): prepareDirty (0.00, 0.00, 480.00, 800.00) opaque 1 <0x600d8ce0>
01-23 21:51:35.634: D/OpenGLRenderer(24057): finish <0x600d8ce0>
01-23 21:51:35.665: D/OpenGLRenderer(24057): prepareDirty (0.00, 0.00, 480.00, 800.00) opaque 1 <0x600d8ce0>
01-23 21:51:35.667: D/OpenGLRenderer(24057): finish <0x600d8ce0>
01-23 21:51:35.680: D/OpenGLRenderer(24057): prepareDirty (0.00, 0.00, 480.00, 800.00) opaque 1 <0x600d8ce0>
01-23 21:51:35.682: D/OpenGLRenderer(24057): finish <0x600d8ce0>
01-23 21:51:35.697: D/OpenGLRenderer(24057): prepareDirty (0.00, 0.00, 480.00, 800.00) opaque 1 <0x600d8ce0>
01-23 21:51:35.699: D/OpenGLRenderer(24057): finish <0x600d8ce0>
01-23 21:51:35.713: D/OpenGLRenderer(24057): prepareDirty (0.00, 0.00, 480.00, 800.00) opaque 1 <0x600d8ce0>
01-23 21:51:35.715: D/OpenGLRenderer(24057): finish <0x600d8ce0>
01-23 21:51:35.728: D/OpenGLRenderer(24057): prepareDirty (0.00, 0.00, 480.00, 800.00) opaque 1 <0x600d8ce0>
01-23 21:51:35.731: D/OpenGLRenderer(24057): finish <0x600d8ce0>
01-23 21:51:35.744: D/OpenGLRenderer(24057): prepareDirty (0.00, 0.00, 480.00, 800.00) opaque 1 <0x600d8ce0>
01-23 21:51:35.747: D/OpenGLRenderer(24057): finish <0x600d8ce0>
01-23 21:51:35.760: D/OpenGLRenderer(24057): prepareDirty (0.00, 0.00, 480.00, 800.00) opaque 1 <0x600d8ce0>
01-23 21:51:35.762: D/OpenGLRenderer(24057): finish <0x600d8ce0>
01-23 21:51:35.775: D/OpenGLRenderer(24057): prepareDirty (0.00, 0.00, 480.00, 800.00) opaque 1 <0x600d8ce0>
01-23 21:51:35.777: D/OpenGLRenderer(24057): finish <0x600d8ce0>
01-23 21:51:35.791: D/OpenGLRenderer(24057): prepareDirty (0.00, 0.00, 480.00, 800.00) opaque 1 <0x600d8ce0>
01-23 21:51:35.793: D/OpenGLRenderer(24057): finish <0x600d8ce0>
01-23 21:51:35.807: D/OpenGLRenderer(24057): prepareDirty (0.00, 0.00, 480.00, 800.00) opaque 1 <0x600d8ce0>
01-23 21:51:35.809: D/OpenGLRenderer(24057): finish <0x600d8ce0>
01-23 21:51:35.823: D/OpenGLRenderer(24057): prepareDirty (0.00, 0.00, 480.00, 800.00) opaque 1 <0x600d8ce0>
01-23 21:51:35.824: D/OpenGLRenderer(24057): finish <0x600d8ce0>
01-23 21:51:35.838: D/OpenGLRenderer(24057): prepareDirty (0.00, 0.00, 480.00, 800.00) opaque 1 <0x600d8ce0>
01-23 21:51:35.840: D/OpenGLRenderer(24057): finish <0x600d8ce0>
01-23 21:51:35.854: D/OpenGLRenderer(24057): prepareDirty (0.00, 0.00, 480.00, 800.00) opaque 1 <0x600d8ce0>
01-23 21:51:35.856: D/OpenGLRenderer(24057): finish <0x600d8ce0>
01-23 21:51:35.870: D/OpenGLRenderer(24057): prepareDirty (0.00, 0.00, 480.00, 800.00) opaque 1 <0x600d8ce0>
01-23 21:51:35.872: D/OpenGLRenderer(24057): finish <0x600d8ce0>
01-23 21:51:35.887: D/OpenGLRenderer(24057): prepareDirty (0.00, 0.00, 480.00, 800.00) opaque 1 <0x600d8ce0>
01-23 21:51:35.889: D/OpenGLRenderer(24057): finish <0x600d8ce0>
01-23 21:51:35.903: D/OpenGLRenderer(24057): prepareDirty (0.00, 0.00, 480.00, 800.00) opaque 1 <0x600d8ce0>
01-23 21:51:35.904: D/OpenGLRenderer(24057): finish <0x600d8ce0>
01-23 21:51:35.916: D/OpenGLRenderer(24057): prepareDirty (0.00, 0.00, 480.00, 800.00) opaque 1 <0x600d8ce0>
01-23 21:51:35.917: D/OpenGLRenderer(24057): finish <0x600d8ce0>
01-23 21:51:35.932: D/OpenGLRenderer(24057): prepareDirty (0.00, 0.00, 480.00, 800.00) opaque 1 <0x600d8ce0>
01-23 21:51:35.933: D/OpenGLRenderer(24057): finish <0x600d8ce0>
01-23 21:51:35.948: D/OpenGLRenderer(24057): prepareDirty (0.00, 0.00, 480.00, 800.00) opaque 1 <0x600d8ce0>
01-23 21:51:35.949: D/OpenGLRenderer(24057): finish <0x600d8ce0>
01-23 21:51:35.963: D/OpenGLRenderer(24057): prepareDirty (0.00, 0.00, 480.00, 800.00) opaque 1 <0x600d8ce0>
01-23 21:51:35.965: D/OpenGLRenderer(24057): finish <0x600d8ce0>
01-23 21:51:35.977: I/System.out(24057): [CDS]rx timeout:1
01-23 21:51:35.977: I/System.out(24057): [CDS]rx timeout:1
01-23 21:51:35.977: D/NativeCrypto(24057): ssl=0x60d443b8 sslRead buf=0x4257ad40 len=1500,timeo=10
01-23 21:51:35.982: D/OpenGLRenderer(24057): prepareDirty (0.00, 0.00, 480.00, 800.00) opaque 1 <0x600d8ce0>
01-23 21:51:35.984: D/OpenGLRenderer(24057): finish <0x600d8ce0>
01-23 21:51:35.990: I/System.out(24057): [CDS]rx timeout:0
01-23 21:51:35.991: I/System.out(24057): [CDS]rx timeout:0
01-23 21:51:35.991: I/System.out(24057): [CDS]rx timeout:0
01-23 21:51:35.991: I/System.out(24057): [CDS]rx timeout:0
01-23 21:51:35.991: D/NativeCrypto(24057): ssl=0x60d443b8 sslWrite buf=0x4257b348 len=675 write_timeout_millis=0
01-23 21:51:35.992: D/NativeCrypto(24057): ssl=0x60d443b8 sslRead buf=0x4257ad40 len=1500,timeo=0
01-23 21:51:35.997: D/OpenGLRenderer(24057): prepareDirty (0.00, 0.00, 480.00, 800.00) opaque 1 <0x600d8ce0>
01-23 21:51:35.999: D/OpenGLRenderer(24057): finish <0x600d8ce0>
01-23 21:51:36.    012: D/OpenGLRenderer(24057): prepareDirty (0.00, 0.00, 480.00, 800.00) opaque 1 <0x600d8ce0>
01-23 21:51:36.    014: D/OpenGLRenderer(24057): finish <0x600d8ce0>
01-23 21:51:36.028: D/OpenGLRenderer(24057): prepareDirty (0.00, 0.00, 480.00, 800.00) opaque 1 <0x600d8ce0>
01-23 21:51:36.030: D/OpenGLRenderer(24057): finish <0x600d8ce0>
01-23 21:51:36.044: D/OpenGLRenderer(24057): prepareDirty (0.00, 0.00, 480.00, 800.00) opaque 1 <0x600d8ce0>
01-23 21:51:36.045: D/OpenGLRenderer(24057): finish <0x600d8ce0>
01-23 21:51:36.059: D/OpenGLRenderer(24057): prepareDirty (0.00, 0.00, 480.00, 800.00) opaque 1 <0x600d8ce0>
01-23 21:51:36.061: D/OpenGLRenderer(24057): finish <0x600d8ce0>
01-23 21:51:36.075: D/OpenGLRenderer(24057): prepareDirty (0.00, 0.00, 480.00, 800.00) opaque 1 <0x600d8ce0>
01-23 21:51:36.077: D/OpenGLRenderer(24057): finish <0x600d8ce0>
01-23 21:51:36.091: D/OpenGLRenderer(24057): prepareDirty (0.00, 0.00, 480.00, 800.00) opaque 1 <0x600d8ce0>
01-23 21:51:36.093: D/OpenGLRenderer(24057): finish <0x600d8ce0>
01-23 21:51:36.107: D/OpenGLRenderer(24057): prepareDirty (0.00, 0.00, 480.00, 800.00) opaque 1 <0x600d8ce0>
01-23 21:51:36.114: D/OpenGLRenderer(24057): finish <0x600d8ce0>
01-23 21:51:36.140: D/OpenGLRenderer(24057): prepareDirty (0.00, 0.00, 480.00, 800.00) opaque 1 <0x600d8ce0>
01-23 21:51:36.146: D/OpenGLRenderer(24057): finish <0x600d8ce0>
01-23 21:51:36.169: D/OpenGLRenderer(24057): prepareDirty (0.00, 0.00, 480.00, 800.00) opaque 1 <0x600d8ce0>
01-23 21:51:36.170: D/OpenGLRenderer(24057): finish <0x600d8ce0>
01-23 21:51:36.185: D/OpenGLRenderer(24057): prepareDirty (0.00, 0.00, 480.00, 800.00) opaque 1 <0x600d8ce0>
01-23 21:51:36.186: D/OpenGLRenderer(24057): finish <0x600d8ce0>
01-23 21:51:36.200: D/OpenGLRenderer(24057): prepareDirty (0.00, 0.00, 480.00, 800.00) opaque 1 <0x600d8ce0>
01-23 21:51:36.2    01: D/OpenGLRenderer(24057): finish <0x600d8ce0>
01-23 21:51:36.216: D/OpenGLRenderer(24057): prepareDirty (0.00, 0.00, 480.00, 800.00) opaque 1 <0x600d8ce0>
01-23 21:51:36.217: D/OpenGLRenderer(24057): finish <0x600d8ce0>
01-23 21:51:36.232: D/OpenGLRenderer(24057): prepareDirty (0.00, 0.00, 480.00, 800.00) opaque 1 <0x600d8ce0>
01-23 21:51:36.233: D/OpenGLRenderer(24057): finish <0x600d8ce0>
01-23 21:51:36.265: D/OpenGLRenderer(24057): prepareDirty (0.00, 0.00, 480.00, 800.00) opaque 1 <0x600d8ce0>
01-23 21:51:36.266: D/OpenGLRenderer(24057): finish <0x600d8ce0>
01-23 21:51:36.296: D/OpenGLRenderer(24057): prepareDirty (0.00, 0.00, 480.00, 800.00) opaque 1 <0x600d8ce0>
01-23 21:51:36.298: D/OpenGLRenderer(24057): finish <0x600d8ce0>
01-23 21:51:36.327: I/BufferQueue(24057): [unnamed-24057-3](this:0x6005a538,id:3,api:1,p:24057,c:24057) [release] fps:53.43, dur:1    010.59, max:32.99, min:0.50
01-23 21:51:36.329: D/OpenGLRenderer(24057): prepareDirty (0.00, 0.00, 480.00, 800.00) opaque 1 <0x600d8ce0>

使用

SupportMapFragment mapFragment = (SupportMapFragment)getSupportFragmentManager().findFragmentById(R.id.map); 
    googleMap = mapFragment.getMap();

而不是

 googleMap = ((MapFragment) getFragmentManager().findFragmentById(
                R.id.map)).getMap();

并添加

class="com.google.android.gms.maps.SupportMapFragment" 

而不是

android:name="com.google.android.gms.maps.MapFragment"

在你的片段中 xml..

更新

你的 class 应该扩展 FragmentActivity..所以替换

public class GpsActivity extends Activity {

public class GpsActivity extends FragmentActivity{

更新2

添加此删除 android.view.InflateException: Binary XML file line #6: Error inflating class fragment

<meta-data
    android:name="com.google.android.gms.version"
    android:value="@integer/google_play_services_version" />