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

  • Home
  • SEARCH
  • 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 8954639
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T14:21:11+00:00 2026-06-15T14:21:11+00:00

I am currently designing an application that needs to plot a route on a

  • 0

I am currently designing an application that needs to plot a route on a MapView. For this to function correctly I need to get data from a KML document that i get from:

http://maps.google.com/maps?f=d&hl=en&saddr=-33.882993,18.63486&daddr=-33.870162,18.657837&ie=UTF8&0&om=0&output=kml

I have created a test project to ensure that this data is received correctly. The problem is that it runs perfectly on my emulator, but not on the actual android phone.

The following piece of code starts a thread when a button is clicked, getting an input stream response (KML).

public void onClick(View v) {
        if (v.getId()== R.id.btn1)
        {   
              new Thread() {
                 @Override
                 public void run() {
                    String url = "http://maps.google.com/maps?f=d&hl=en&saddr=-33.882993,18.63486&daddr=-33.870162,18.657837&ie=UTF8&0&om=0&output=kml";
                    InputStream is = getConnection(url);

                    mRoad = RouteProvider.getRoute(is);
                    mHandler.sendEmptyMessage(0);
                 }
             }.start(); 
        }   

}

private InputStream getConnection(String url) {
    InputStream is = null;
    try {
           HttpURLConnection conn = (HttpURLConnection)new URL(url).openConnection();
            conn.connect();
            is = conn.getInputStream();
            conn = null;
    } catch (MalformedURLException e) {
            e.printStackTrace();
    } catch (IOException e) {
            e.printStackTrace();
    }
     return is;
    }

For the moment, all getRoute() needs to do is give the contents of the “LineString” element inside the KML Document. These contents are a list of coordinates that can be used to draw a route.

public class RouteProvider {
    /** Gets data from KML response **/
    public static Road getRoute(InputStream is) {
        Road road = new Road();

        try 
        {
            Document xmlDoc = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(is);
            NodeList a = xmlDoc.getElementsByTagName("LineString");
            System.out.println(a.item(0).getTextContent());
            road.mName = a.item(0).getTextContent();


        } catch (SAXException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        } catch (ParserConfigurationException e) {
            e.printStackTrace();
        }   


        return road;
      }

On the emulator I am running the correct value is displayed within road.mName, which is a list of coordinates. On a Android phone it displays null?

I am building for Android 2.3.3 on eclipse and I used a Samsung Galaxy S2 for testing.

  • 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-06-15T14:21:12+00:00Added an answer on June 15, 2026 at 2:21 pm

    Did not need to use KML after all. Just used google maps to supply xml format. Much easier.
    https://developers.google.com/maps/documentation/directions/

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Let's say that I'm currently designing an application where I will need to use
I'm currently designing this website http://avs.mybigcommerce.com . The problem is that my styles.css isn't
I am currently designing a class library that will provide data to a web
I'm designing an application that processes RSS feeds using MongoDB. Currently my collections are
(Let me give you some context) I am currently designing an application that is
I am currently re-designing an application and stumbled upon a problem serializing some data.
I'm currently designing a mobile application that can send and read messages to a
I am currently designing a web application that will allow users to schedule tasks
I'm currently designing/reworking the databinding part of an application that makes heavy use of
I'm currently designing a windows mobile application using compact framework 3.5 and I need

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.