Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

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

java - Couldn't get connection factory client

everything is working fine but the problem when i am map a location nothing nothing happen i registered my google map and i did every instruction here

http://code.google.com/intl/pl/android/add-ons/google-apis/mapkey.html

i can see the map i can zoom in & out but when i am searching for a location i am getting this in logcat

05-01 12:59:35.512: ERROR/MapActivity(488): Couldn't get connection factory client
05-01 12:59:36.012: INFO/ActivityManager(70): Displayed TaskManager.com/.AddLocationMapActivity: +4s562ms
05-01 12:59:36.692: WARN/KeyCharacterMap(488): No keyboard for id 0
05-01 12:59:36.692: WARN/KeyCharacterMap(488): Using default keymap: /system/usr/keychars/qwerty.kcm.bin
05-01 12:59:41.192: DEBUG/dalvikvm(238): GC_EXPLICIT freed 6K, 54% free 2543K/5511K, external 410K/517K, paused 77ms
05-01 12:59:46.352: DEBUG/dalvikvm(318): GC_EXPLICIT freed 6K, 54% free 2597K/5639K, external 410K/517K, paused 158ms
05-01 12:59:51.362: DEBUG/dalvikvm(352): GC_EXPLICIT freed <1K, 54% free 2539K/5511K, external 410K/517K, paused 144ms
05-01 12:59:54.262: WARN/System.err(488): java.io.IOException: Service not Available
05-01 12:59:54.272: WARN/System.err(488):     at android.location.Geocoder.getFromLocationName(Geocoder.java:178)
05-01 12:59:54.282: WARN/System.err(488):     at TaskManager.com.AddLocationMapActivity.mapCurrentLocation(AddLocationMapActivity.java:59)
05-01 12:59:54.282: WARN/System.err(488):     at TaskManager.com.AddLocationMapActivity$1.onClick(AddLocationMapActivity.java:49)
05-01 12:59:54.292: WARN/System.err(488):     at android.view.View.performClick(View.java:2485)
05-01 12:59:54.302: WARN/System.err(488):     at android.view.View$PerformClick.run(View.java:9080)
05-01 12:59:54.302: WARN/System.err(488):     at android.os.Handler.handleCallback(Handler.java:587)
05-01 12:59:54.332: WARN/System.err(488):     at android.os.Handler.dispatchMessage(Handler.java:92)
05-01 12:59:54.332: WARN/System.err(488):     at android.os.Looper.loop(Looper.java:123)
05-01 12:59:54.342: WARN/System.err(488):     at android.app.ActivityThread.main(ActivityThread.java:3683)
05-01 12:59:54.342: WARN/System.err(488):     at java.lang.reflect.Method.invokeNative(Native Method)
05-01 12:59:54.352: WARN/System.err(488):     at java.lang.reflect.Method.invoke(Method.java:507)
05-01 12:59:54.362: WARN/System.err(488):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
05-01 12:59:54.362: WARN/System.err(488):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
05-01 12:59:54.372: WARN/System.err(488):     at dalvik.system.NativeStart.main(Native Method)

and here is my java code

 protected void mapCurrentLocation() {
            String addressString = addressText.getText().toString();
            Geocoder g = new Geocoder(this,Locale.getDefault());
            List<Address> addresses;
            try
            {
//when i use the debugger i get exception at next line 
                addresses = g.getFromLocationName(addressString, 1);
                if(null != addresses && addresses.size()>0)
                {
                    address=addresses.get(0);
                    List<Overlay> mapOverlay=mapView.getOverlays();
                    AdreesOverlay addressoverlay = new AdreesOverlay(address);
                    mapOverlay.add(addressoverlay);
                    mapView.invalidate();
                    final MapController mapController=mapView.getController();
                    mapController.animateTo(addressoverlay.getGeopoint(),new Runnable(){
                        public void run() { 
                            mapController.setZoom(12);
                        }});
                }
                else
                {

                }
            }
            catch(IOException exception)
            {
                exception.printStackTrace();
            }
        }

any help ? thanks in advance

See Question&Answers more detail:os

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

1 Reply

0 votes
by (71.8m points)

If you are running this in an emulator either version API 8 or API 9, this is a known bug with the emulator, see this bug report service not available

I find the same behaviour. I can get it to work on an API level 7 emulator (2.1), although sometimes it fails, so I have my code try twice before popping up a "geocoder error" Toast.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...