Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
247 views
in Technique[技术] by (71.8m points)

android - Couldn't get connection factory client - fighting with Google Maps

another day another problem, I finally managed to set up correctly google maps on my android application, or at least I thought I've done it, the whole progam starts, it even call the class which should "print" a map, but the only thing I can see is a grid with google label on it [ in the corner ]. I've checked the dalvik monitor and the error

E/MapActivity(394): Couldn't get connection factory client

occurs. I've find out on stackoverflow website that I should sent a gps signal or sth like this from dalvik monitor, and I've done it. Nothing happend, also I got the api key one more time, but nothing changed.

here is 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>

here is a 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> 

my view

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
E/MapActivity(394): Couldn't get connection factory client 

This will not be issue in your case. It's just warning message.

For using Map,things you need to Keep in mind :

1.Add internet permission in Manifest file

    <uses-permission android:name="android.permission.INTERNET" />

2.Add Library code in Manifest file :

 <uses-library android:name="com.google.android.maps" /> 
  1. Extend Map Activity instead of Activity also ensure that your SDK is Google not Android

  2. Then generate Map Key using Release Key and not by using Default Android Debug key Check this post for creating Key using Release Key.

For further references check this link Mobi Forge

Output of your code


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...