谷歌地图api v2在android中显示空白屏幕?

时间:2015-05-04 16:44:10

标签: android google-maps

这是我的manifest.xml:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="us.datn_02">
    <uses-sdk
        android:minSdkVersion="11"
        android:targetSdkVersion="21" />
    <permission
        android:name="us.datn_02.permission.MAPS_RECEIVE"
        android:protectionLevel="signature" />
    <uses-permission android:name="us.datn_02.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"/>
    <uses-feature
        android:glEsVersion="0x00020000"
        android:required="true" />
    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_home"
        android:label="@string/app_name"
        android:theme="@style/Theme.MyCompatTheme" >
        <meta-data
            android:name="com.google.android.maps.v2.API_KEY"
            android:value="api key here" />
        <meta-data
            android:name="com.google.android.gms.version"
            android:value="@integer/google_play_services_version" />
        <activity
            android:name=".home.Home"
            android:icon="@drawable/ic_home"
            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="us.datn_02.map.Map"
            android:label="@string/title_activity_map" >
        </activity>
    </application>
</manifest>

activity_map.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=".Map" >
    <fragment
        android:id="@+id/map"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        class="com.google.android.gms.maps.SupportMapFragment" />
</RelativeLayout>

这是我在 Map.class

中的代码
public class Map extends FragmentActivity {

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

    // Initializing

    // Getting reference to SupportMapFragment of the activity_main
    SupportMapFragment fm = (SupportMapFragment) getSupportFragmentManager()
            .findFragmentById(R.id.map);

    // Getting Map for the SupportMapFragment
    map = fm.getMap();

    GooglePlayServicesUtil
            .isGooglePlayServicesAvailable(getApplicationContext());
}

我得到包名为api的密钥是:us.datn_02。

地图活动是家庭活动的孩子。

为什么我在地图活动中得到空白?

有人可以帮我吗?

1 个答案:

答案 0 :(得分:0)

用实际生成的android-api密钥替换&#34; api密钥&#34;

/usr/sbin/setsebool httpd_can_network_connect=1