在我的应用程序中,我使用了谷歌地图功能。为此,我使用了自己的密钥库并创建了 MD5 指纹。后来我从谷歌获得了基于 MD5 的 xml。
问题:
它在模拟器中工作。但在真实设备中没有显示任何内容。但是网格是可见的。
样本--类
public class First extends MapActivity {
private MapController mc;
private MapView mapView;
private static double current_lat;
private static double current_long;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
mapView = (MapView) findViewById(R.id.mapview);
mc = mapView.getController();
LocationManager mlocManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
mlocManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, mNetworkListener);
GeoPoint p = new GeoPoint((int)current_lat*(1000000), (int)current_long*(1000000));
mc.animateTo(p);
}
private static LocationListener mNetworkListener = new LocationListener()
{
public void onLocationChanged(Location location) {
makeUseOfNewLocation(location);
}
public void onProviderDisabled(String provider) {
// TODO Auto-generated method stub
}
public void onProviderEnabled(String provider) {
// TODO Auto-generated method stub
}
public void onStatusChanged(String provider, int status, Bundle extras) {}
public void makeUseOfNewLocation(Location location) {
current_lat = location.getLatitude();
current_long = location.getLongitude();
System.out.println("*** i'm here"+current_lat);
}
};
@Override
protected boolean isRouteDisplayed() {
// TODO Auto-generated method stub
return false;
}
安卓清单
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<activity
android:name=".First"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<uses-library android:name="com.google.android.maps" />
</application>
主要的
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<com.google.android.maps.MapView
android:id="@+id/mapview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:apiKey="0wINx0c2YuEd3mkyPwidZyeoz_HiyN3jrts-Q" />
</LinearLayout>
日志猫
08-10 14:27:56.841: W/MapActivity(20815): Recycling dispatcher android_maps_conflict_avoidance.com.google.googlenav.datarequest.DataRequestDispatcher@405b 9458
08-10 14:27:56.851: V/MapActivity(20815): Recycling map object.
08-10 14:27:56.901: I/MapActivity(20815): Handling network change notification:CONNECTED
08-10 14:27:56.901: E/MapActivity(20815): Couldn't get connection factory client
任何人都可以弄清楚为什么地图没有显示在设备中。提前谢谢