我有很多教程,做了所有事情但没有显示地图我总是以地图的缩放控制视图结束,我认为清单有问题
我的代码如下所示
显现:
<application android:icon="@drawable/logo" android:label="@string/app_name" >
<activity android:name=".Main" android:noHistory="true"
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="my api key"/>
<activity android:name="Activity2" android:label="@string/app_name" android:configChanges="keyboardHidden|orientation" />
</application>
<uses-sdk android:minSdkVersion="9" android:targetSdkVersion="10" />
<uses-feature android:glEsVersion="0x00020000" android:required="true"/>
<uses-permission android:name="my_package_name.permission.MAPS_RECEIVE"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<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-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.CLEAR_APP_USER_DATA" />
<uses-permission android:name="android.permission.CLEAR_APP_CACHE" />
<uses-permission android:name="android.permission.SEND_SMS" />
<uses-permission android:name="android.permission.RECEIVE_SMS" />
<uses-permission android:name="android.permission.WRITE_SMS" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.CALL_PHONE" />
<uses-permission android:name="android.permission.READ_LOGS" />
我的 mapview.xml 是
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<fragment
xmlns:map="http://schemas.android.com/apk/res-auto"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:id="@+id/map"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
我的主要活动课
public class Main extends FragmentActivity {
private String sResponse;
static final LatLng HAMBURG = new LatLng(53.558, 9.927);
static final LatLng KIEL = new LatLng(53.551, 9.993);
private GoogleMap map;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
try{
setContentView(R.layout.mapview);
GoogleMap map = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map)).getMap();
LatLng sydney = new LatLng(-33.867, 151.206);
map.setMyLocationEnabled(true);
map.moveCamera(CameraUpdateFactory.newLatLngZoom(sydney, 13));
map.addMarker(new MarkerOptions()
.title("Sydney")
.snippet("The most populous city in Australia.")
.position(sydney));
}
catch(Exception ex){
}
}
我不知道出了什么问题,我还从 SDK 将支持库 google-play-service_lib 导入到项目中 谁能告诉我哪里出错了提前谢谢!
编辑
当我在清单中添加此权限时
<permission
android:name="my_package_name.permission.MAPS_RECEIVE"
android:protectionLevel="signature" />
它给了我错误
Installation error: INSTALL_PARSE_FAILED_MANIFEST_MALFORMED
Please check logcat output for more details.
Launch canceled!
任何帮助..?