- 当我将 APK 上传到设备时,我看不到地图。
- 我已经尝试过使用 FragmentActivity 并且可以毫无问题地看到地图,但在这种情况下使用 MapActivity 不会。
- Google Maps Android API v2 服务已开启。任何想法?提前致谢!
代码:
package com.avargas.mapas2;
import android.os.Bundle;
import android.view.Menu;
import com.avargas.mapas2.R;
import com.google.android.maps.MapActivity;
import com.google.android.maps.MapView;
public class MainActivity extends MapActivity {
private MapView mapa;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mapa = (MapView) this.findViewById(R.id.mapview);
mapa.setBuiltInZoomControls(true);
mapa.setTraffic(true);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
@Override
protected boolean isRouteDisplayed() {
// TODO Auto-generated method stub
return false;
}
}
活动 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" >
<com.google.android.maps.MapView
android:id="@+id/mapview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:clickable="true"
android:apiKey="AIzaSyCkYNO20ZR0rNTkF-O7g-i0e54SIsU1W5s"/>
</RelativeLayout>
显现:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.avargas.mapas2"
android:versionCode="1"
android:versionName="1.0" >
<uses-feature
android:glEsVersion="0x00020000"
android:required="true"/>
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<permission
android:name="com.avargas.mapas2.permission.MAPS_RECEIVE"
android:protectionLevel="signature" />
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="com.avargas.mapas2.permission.MAPS_RECEIVE" />
<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-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<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="com.avargas.mapas2.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>
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="AIzaSyCkYNO20ZR0rNTkF-O7g-i0e54SIsU1W5s"/>
</application>
</manifest>
接口:
API key:
AIzaSyCkYNO20ZR0rNTkF-O7g-i0e54SIsU1W5s
Android apps:
8F:AA:26:71:BC:77:61:A3:34:1C:55:DC:46:AE:BD:35:97:50:A5:22;com.avargas.mapas2
Activated on: Apr 19, 2013 2:58 PM
Activated by: you