我实施了谷歌地图android api v2。虽然我可以看到地图区域,我已经尝试了所有其他来源..!这就是我可以查看的所有输出...请帮助..!
我的MapActivity.java
package nav.android.app.navigationsystem;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.MapFragment;
import android.os.Bundle;
import android.app.Activity;
import android.util.Log;
import android.widget.Toast;
import android.view.Menu;
public class MapActivity extends Activity {
// Google Map
public GoogleMap googleMap;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_map);
try {
Log.e("loading map. . . .","loading map. . . ");
// Loading map
initilizeMap();
} catch (Exception e) {
Log.e("catch. . .", "catch. . .");
e.printStackTrace();
}
/* MapFunctionality mf = new MapFunctionality();
mf.currentLoc();
mf.addMarker();*/
}
/**
* function to load map. If map is not created it will create it for you
* */
private void initilizeMap() {
// MapFunctionality mf = new MapFunctionality();
Log.e("initializing map. . . ","initializing map. . ");
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();
}
// mf.currentLoc();
// mf.addMarker();
}
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.map, menu);
return true;
}
@Override
protected void onResume() {
super.onResume();
initilizeMap();
}
}
我的宣言文件
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="nav.android.app.navigationsystem"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="11"
android:targetSdkVersion="19" />
<permission
android:name="info.androidhive.googlemapsv2.permission.MAPS_RECEIVE"
android:protectionLevel="signature"></permission>
<uses-permission android:name="info.androidhive.googlemapsv2.permission.MAPS_RECEIVE" />
<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" />
<!-- Required OpenGL ES 2.0. for Maps V2 -->
<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" >
<activity
android:name="nav.android.app.navigationsystem.MapActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="nav.anoid.app.navigationsystem.MAPACTIVITY"/>
</intent-filter>
</activity>
<meta-data
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
<!-- Goolge Maps API Key -->
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="AIzaSyDi4EDHhxyY1-Tbpk2XN7ZbnSIqQ-7iIWo" />
<activity
android:name="nav.android.app.navigationsystem.StartingActivity"
android:label="@string/title_activity_starting" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</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"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MapActivity" >
<fragment
android:id="@+id/map"
android:name="com.google.android.gms.maps.MapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentTop="true" />
</RelativeLayout>
答案 0 :(得分:0)
这是小清单
顺便说一句。您可以删除MapsReceive权限
答案 1 :(得分:0)
在你的清单中试试这个:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="nav.android.app.navigationsystem"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="13"
android:targetSdkVersion="17" />
<permission
android:name="nav.android.app.navigationsystem.permission.MAPS_RECEIVE"
android:protectionLevel="signature" />
<uses-feature
android:glEsVersion="0x00020000"
android:required="true" />
<uses-permission android:name="nav.android.app.navigationsystem.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-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" >
<activity
android:name="nav.android.app.navigationsystem.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="AIzaSyDi4EDHhxyY1-Tbpk2XN7ZbnSIqQ-7iIWo" />
</application>
</manifest>