Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6614785
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T20:22:50+00:00 2026-05-25T20:22:50+00:00

I am using a URL connection to connect Google maps web service and get

  • 0

I am using a URL connection to connect Google maps web service and get the result in KML format and parse it and display it on MapView. I put this operations in a thread, but I get this error that I don’t know what does it mean ?!
please help me in finding out what is this error and what is the solution ?

09-28 23:00:45.026: ERROR/ActivityManager(67): ANR in com.android.uis (com.android.uis/.RoutingMapActivity)
09-28 23:00:45.026: ERROR/ActivityManager(67): Reason: keyDispatchingTimedOut
09-28 23:00:45.026: ERROR/ActivityManager(67): Load: 0.49 / 0.21 / 0.15
09-28 23:00:45.026: ERROR/ActivityManager(67): CPU usage from 22714ms to 0ms ago:
09-28 23:00:45.026: ERROR/ActivityManager(67):   99% 1049/com.android.uis: 98% user + 0.4% kernel / faults: 159 minor
09-28 23:00:45.026: ERROR/ActivityManager(67):   0.4% 199/com.google.process.gapps: 0.2% user + 0.1% kernel / faults: 52 minor
09-28 23:00:45.026: ERROR/ActivityManager(67):   0.1% 67/system_server: 0% user + 0% kernel
09-28 23:00:45.026: ERROR/ActivityManager(67):   0% 40/adbd: 0% user + 0% kernel
09-28 23:00:45.026: ERROR/ActivityManager(67):   0% 131/com.android.systemui: 0% user + 0% kernel / faults: 1 minor
09-28 23:00:45.026: ERROR/ActivityManager(67): 100% TOTAL: 99% user + 0.7% kernel
09-28 23:00:45.026: ERROR/ActivityManager(67): CPU usage from 996ms to 1566ms later:
09-28 23:00:45.026: ERROR/ActivityManager(67):   91% 1049/com.android.uis: 91% user + 0% kernel / faults: 2 minor
09-28 23:00:45.026: ERROR/ActivityManager(67):     89% 1049/com.android.uis: 89% user + 0% kernel
09-28 23:00:45.026: ERROR/ActivityManager(67):   10% 67/system_server: 5.2% user + 5.2% kernel / faults: 6 minor
09-28 23:00:45.026: ERROR/ActivityManager(67):     8.7% 97/InputDispatcher: 3.5% user + 5.2% kernel
09-28 23:00:45.026: ERROR/ActivityManager(67):     1.7% 68/HeapWorker: 0% user + 1.7% kernel
09-28 23:00:45.026: ERROR/ActivityManager(67): 100% TOTAL: 94% user + 5.2% kernel

MapActivity class

package com.android.uis;

import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
import java.util.List;

import android.content.Context;
import android.graphics.drawable.Drawable;
import android.location.Criteria;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;

import com.android.geo.Road;
import com.android.geo.RoadProvider;
import com.android.maps.MyItemizedOverlay;
import com.google.android.maps.GeoPoint;
import com.google.android.maps.MapActivity;
import com.google.android.maps.MapView;
import com.google.android.maps.Overlay;
import com.google.android.maps.OverlayItem;

public class RoutingMapActivity extends MapActivity implements LocationListener {

    // Key : 0ObBrVVNjsIA__m7D1lmsednIXg6pcDRBG-Qvfg
    MapView mapView;
    List<Overlay> mapOverlays;
    Drawable drawable;
    Drawable drawable2;
    MyItemizedOverlay itemizedOverlay;
    MyItemizedOverlay itemizedOverlay2;
    LocationManager locationManager;
    private String provider;
    private Road mRoad;
    private Handler mHandler;
    @Override
    public void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);
        setContentView(R.layout.map_layout);
        initMap();
        //initMyLocation();

    }
    private void initMap(){
        mapView = (MapView) findViewById(R.id.google_maps);
        mapView.setBuiltInZoomControls(true);       
        mapOverlays = mapView.getOverlays();

        new Thread(){


            @Override
            public void run(){
                double fromLat = 49.85, fromLon= 24.016667, toLat = 50.45, toLon = 30.523333;
                String url = RoadProvider.getUrl(fromLat, fromLon, toLat, toLon);
                InputStream is = getConnection(url);
                mRoad = RoadProvider.getRoute(is);
                mHandler.sendEmptyMessage(0);

            }
        }.start();

        mHandler = new Handler(){
            public void handleMessage(Message msg){
                //drawable2 = getResources().getDrawable(R.drawable.marker2);
                drawable = getResources().getDrawable(R.drawable.marker);
                itemizedOverlay2 = new MyItemizedOverlay(drawable, mapView,mRoad);
                mapOverlays.clear();
                for(int i=0; i<mRoad.mRoute.length;i++){
                    addPoint("","",new GeoPoint((int)(mRoad.mRoute[i][1]*1E6),(int)(mRoad.mRoute[i][0]*1E6)),itemizedOverlay2);
                }
                //addPoint("Point 2.","Point 2.",(int)(51.515259*1E6),(int)(-0.086623*1E6),itemizedOverlay2);
                mapOverlays.add(itemizedOverlay2);
                mapView.invalidate();
            };
        };


    }
    private InputStream getConnection(String url){
        InputStream is = null;
        try {
            URLConnection urlConn= new URL(url).openConnection();
            is= urlConn.getInputStream();
        } catch (MalformedURLException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        return is;
    }
    private void addPoint(String name,String description,GeoPoint point, MyItemizedOverlay myItemizedOverlay){
        OverlayItem overlayItem = new OverlayItem(point,name,description);
        myItemizedOverlay.addOverlay(overlayItem);
    }
    private void initMyLocation(){
        locationManager =(LocationManager)getSystemService(Context.LOCATION_SERVICE);
        Criteria criteria=new Criteria();
        provider = locationManager.getBestProvider(criteria, false);
        Location location = locationManager.getLastKnownLocation(provider);

    }
    @Override
    protected boolean isRouteDisplayed() {
        return false;
    }
    @Override
    public void onLocationChanged(Location arg0) {
        // TODO Auto-generated method stub

    }
    @Override
    public void onProviderDisabled(String arg0) {
        // TODO Auto-generated method stub

    }
    @Override
    public void onProviderEnabled(String arg0) {
        // TODO Auto-generated method stub

    }
    @Override
    public void onStatusChanged(String arg0, int arg1, Bundle arg2) {
        // TODO Auto-generated method stub

    }

}

Edit

I have changed the code to the following .. but still have the same error

private void initMap(){ 
        new DrawRoad().execute("");
    }
    private class DrawRoad extends AsyncTask<String, Void, Road> {
         protected Road doInBackground(String... unused) {
            mapOverlays = mapView.getOverlays();
            double fromLat = 49.85, fromLon= 24.016667, toLat = 50.45, toLon = 30.523333;
            String url = RoadProvider.getUrl(fromLat, fromLon, toLat, toLon);
            InputStream is = getConnection(url);
            mRoad = RoadProvider.getRoute(is);
            return mRoad;
         }

         protected void onPostExecute(Road road) {
            drawable = getResources().getDrawable(R.drawable.marker);
            itemizedOverlay2 = new MyItemizedOverlay(drawable, mapView,road);
            mapOverlays.clear();
            for(int i=0; i<mRoad.mRoute.length;i++){
                addPoint("","",new GeoPoint((int)(road.mRoute[i][1]*1E6),(int)(road.mRoute[i][0]*1E6)),itemizedOverlay2);
            }
            //addPoint("Point 2.","Point 2.",(int)(51.515259*1E6),(int)(-0.086623*1E6),itemizedOverlay2);
            mapOverlays.add(itemizedOverlay2);
            mapView.invalidate();
         }
     }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T20:22:51+00:00Added an answer on May 25, 2026 at 8:22 pm

    You could try using an async task which is simpler, something like:

        private class GetKMLTask extends AsyncTask<String, Integer, String> {
        protected String doInBackground(String... unused) {
            double fromLat = 49.85, fromLon= 24.016667, toLat = 50.45, toLon = 30.523333;
            String url = "";
            InputStream is = getConnection(url);
            //.... get the road here    
            return result;
        }
    
        protected void onPostExecute(String jsonResult) {
            try {
                drawable = getResources().getDrawable(R.drawable.marker);
                itemizedOverlay2 = new MyItemizedOverlay(drawable, mapView,mRoad);
                mapOverlays.clear();
                for(int i=0; i<mRoad.mRoute.length;i++){
                    addPoint("","",new GeoPoint((int)(mRoad.mRoute[i][1]*1E6),(int)(mRoad.mRoute[i][0]*1E6)),itemizedOverlay2);
                }
                //addPoint("Point 2.","Point 2.",(int)(51.515259*1E6),(int)(-0.086623*1E6),itemizedOverlay2);
                mapOverlays.add(itemizedOverlay2);
                mapView.invalidate();
                } 
            catch (Exception e) {
                onFail("");
            }
    
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm currently passing some date-time info to a web page using url parameters, which
I am trying to use java.net to connect to remote URL in Google App
I am trying to connect to DB using the standard JDBC way connection =
Using Java, I get this error when attempting to connect to a mysql database:
Ok so ive already tried using connect-form and I couldnt get it working for
In a Python web application, I am able to connect to Gmail using OAuth
I need to connect to the middleware server using java URL and URLConnection classes
I am using JDBC to connect to a MySQL server (no connection pooling I
I'm trying to parse a webpage using Java with URLConnection. I try to set
I have someone connecting to my repository using the url (substituted the IP address):

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.