另一天另一个问题,我终于设法在我的
Android应用程序上设置正确的谷歌地图,或者至少我以为我已经完成了它,整个程序开始,它甚至调用应该“打印”地图的类,但是我唯一能看到的是一个带有谷歌标签的网格[在角落里].我检查了dalvik监视器和错误
E/MapActivity(394): Couldn’t get connection factory client
发生.我已经在stackoverflow网站上找到了我应该从dalvik监视器发送gps信号或者这样的事情,我已经完成了.没有什么事情发生,我也再次获得了api密钥,但没有任何改变.
这是map.xml
- <?xml version="1.0" encoding="utf-8"?>
- <!-- This file is /res/layout/mapview.xml -->
- <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:orientation="vertical"
- android:layout_width="fill_parent"
- android:layout_height="fill_parent">
- <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:orientation="horizontal"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content">
- <Button android:id="@+id/zoomin"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="+"
- android:onClick="myClickHandler"
- android:padding="12px" />
- <Button android:id="@+id/zoomout"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="-"
- android:onClick="myClickHandler"
- android:padding="12px" />
- <Button android:id="@+id/sat"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="Satellite"
- android:onClick="myClickHandler"
- android:padding="8px" />
- <Button android:id="@+id/street"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="Street"
- android:onClick="myClickHandler"
- android:padding="8px" />
- <Button android:id="@+id/traffic"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="Traffic"
- android:onClick="myClickHandler"
- android:padding="8px" />
- <Button android:id="@+id/normal"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="Normal"
- android:onClick="myClickHandler"
- android:padding="8px" />
- </LinearLayout>
- <com.google.android.maps.MapView
- android:id="@+id/mapview"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:clickable="true"
- android:apiKey="0zPcz1VYRSpLusufJ2JoL0ffl2uxDMovgpW319w" />
- </LinearLayout>
这是一个MapMapa.java
- public class MapMapa extends MapActivity
- {
- private MapView mapView;
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.map);
- mapView = (MapView)findViewById(R.id.mapview);
- }
- public void myClickHandler(View target) {
- switch(target.getId()) {
- case R.id.zoomin:
- mapView.getController().zoomIn();
- break;
- case R.id.zoomout:
- mapView.getController().zoomOut();
- break;
- case R.id.sat:
- mapView.setSatellite(true);
- break;
- case R.id.street:
- mapView.setStreetView(true);
- break;
- case R.id.traffic:
- mapView.setTraffic(true);
- break;
- case R.id.normal:
- mapView.setSatellite(false);
- mapView.setStreetView(false);
- mapView.setTraffic(false);
- break;
- }
- }
- @Override
- protected boolean isLocationDisplayed() {
- return false;
- }
- @Override
- protected boolean isRouteDisplayed() {
- return false;
- }
的manifest.xml
- <?xml version="1.0" encoding="utf-8"?>
- <manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="menu.dot" android:versionCode="1" ndroid:versionName="1.0">
- <application android:label="@string/app_name" android:icon="@drawable/icon">
- <uses-library android:name="com.google.android.maps" />
- <activity android:name="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>
- <activity android:name=".About">
- android:label="@string/about_title"
- android:theme="@android:style/Theme.Dialog" >
- </activity>
- <activity android:name=".Exit">
- andorid:label="@string/exit_title">
- </activity>
- <activity android:name=".Options">
- </activity>
- <activity android:name=".Start">
- </activity>
- <activity android:name=".Create">
- </activity>
- <activity android:name=".Where">
- </activity>
- <activity android:name=".Proceed">
- </activity>
- <activity android:name=".Finish">
- </activity>
- <activity android:name=".Login">
- </activity>
- <activity android:name=".OK">
- </activity>
- <activity android:name=".UserPanel">
- </activity>
- <activity android:name=".Managero">
- </activity>
- <activity android:name=".Edition">
- </activity>
- <activity android:name=".Done">
- </activity>
- <activity android:name=".Delete">
- </activity>
- <activity android:name=".MapMapa">
- </activity>
- </application>
- <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
- <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
- <uses-permission android:name="android.permission.INTERNET"/>
- <uses-sdk android:minSdkVersion="3" />
- </manifest>
解决方法
- E/MapActivity(394): Couldn't get connection factory client
在您的情况下,这不会是问题.这只是警告信息.
要使用Map,请记住以下事项:
- <uses-permission android:name="android.permission.INTERNET" />
- <uses-library android:name="com.google.android.maps" />
>扩展地图活动而不是活动也确保您的SDK是Google而不是Android
>然后使用Release Key生成Map Key,而不是使用Default Android Debug key
查看此帖子以创建Key using Release Key.
如需进一步参考,请查看此链接Mobi Forge