【发布时间】:2012-10-22 05:35:17
【问题描述】:
我尝试使用 Android MapActivity,因此我通过此链接从我的 Debug.keystore MD5 创建了我的 API 密钥 https://developers.google.com/android/maps-api-signup
然后我在我的 Manifest 中设置这行代码:
应用之子
<uses-library android:name="com.google.android.maps" />
这样设置我的权限
<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_GPS" />
<uses-permission android:name="android.permission.ACCESS_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_ASSISTED_GPS" />
并使用我的 api 密钥设置 MapView
<com.google.android.maps.MapView
android:id="@+id/mapview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:apiKey="MY API KEY"
android:clickable="true" />
在 Java 文件 MapActivity 中,我从示例中编写了如下代码:
locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
// Define the criteria how to select the locatioin provider -> use
// default
Criteria criteria = new Criteria();
provider = locationManager.getBestProvider(criteria, false);
Location location = locationManager.getLastKnownLocation(provider);
if (location != null) {
System.out.println("Provider " + provider + " has been selected.");
onLocationChanged(location);}
我的代码过去可以正常工作。我可以通过overlayItem设置我的定位点,但是在我再次查看我的代码而对我的MapActivity什么都不做之后,它不再起作用了。我的 LogCat 向我显示 MapActivity "Couldn't get connection factory client"
我进入 /.android 文件夹并删除了我的 debug.keystore 并从中再次生成我的新 API 密钥,但它仍然无法正常工作。
有人知道如何解决这个问题吗?
编辑:更多信息,位置始终为空。
【问题讨论】: