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 6355605
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T22:47:57+00:00 2026-05-24T22:47:57+00:00

I have an android app that parses strings from this web URL and stores

  • 0

I have an android app that parses strings from this web URL and stores them into an array called phoneNumberList. Then, when the time comes, the phone’s dialer is to be launched, carrying that phone number with it. The problem is, the dialer is showing up blank. Any ideas why?

Here’s my code to parse the XML file and store it in an array:

    try {
            URL url = new URL("http://dl.dropbox.com/u/38725067/webexample/Site%203/index.xml");
            URLConnection conn = url.openConnection();

            DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
            DocumentBuilder builder = factory.newDocumentBuilder();
            Document doc = builder.parse(conn.getInputStream());

            NodeList nodes = doc.getElementsByTagName("phone");
            for (int i = 0; i < nodes.getLength(); i++) {
                Element element = (Element) nodes.item(i);

                NodeList title = element.getElementsByTagName("string");
                Element line = (Element) title.item(0);
                phoneNumberList[i] = getCharacterDataFromElement(line);


            }
    }

… and here’s my code that launches the dialer:

    public void launchDialer(String number){
        String numberToDial = "tel:"+number;
        startActivity(new Intent(Intent.ACTION_DIAL, Uri.parse(numberToDial)));
    }

    public void onClick(View v) {
        String numberToCall = "0";
        switch (v.getId()) {
        case R.id.police_button1:
            numberToCall = Main.phoneNumberList[0];
            launchDialer(numberToCall);
            break;
        case R.id.police_button2:
            launchDialer(Main.phoneNumberList[1]);
            break;

        }
    }

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Note 1: In the URL, you will see I attempted two formats for phone numbers: one with dashes, one without; neither worked.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Note 2: In the latter code snippet, you can see I tried two different ways of calling the number: one using the string numberToCall, and one without the string; neither worked.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Thank you in advanced for any and all help –

Mike Gates

  • 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-24T22:47:59+00:00Added an answer on May 24, 2026 at 10:47 pm

    Maybe getCharacterDataFromElement(line) is not returning the correct data. I didn’t find this function so I replaced it with line.getTextContent()

    In addition there also could exists a problem with your arrays. I would recommend using an ArrayList. This structure automatically resizes when you add a new item. Example code:

    // global definition
    private ArrayList<String> phoneNumberList = new ArrayList<String>();
    
    // parsing numbers
    NodeList nodes = doc.getElementsByTagName("phone");
    for (int i = 0; i < nodes.getLength(); i++) {
        Element element = (Element) nodes.item(i);
        NodeList title = element.getElementsByTagName("string");
        Element line = (Element) title.item(0);
        phoneNumberList.add(line.getTextContent());
    }
    
    // calling number #0
    startActivity(new Intent(Intent.ACTION_DIAL, Uri.parse("tel:"+phoneNumberList.get(0))));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an Android project that branched into three different applications, app-1 , app-2
I have an Android app that talks to .net web service via http over
I have a query in my android app that pulls all image paths from
I have a class that extends android.app.Dialog, the layout is done in an xml
We have an Android app and a Web Service. We want to download part
I'm going to implement my strings with internationalization in my Android app. I have
I have a link from that link: http://api.maxxiscentral.com/maxxiscentral/GetTyrePatterns from this link i want to
I have android app that talks to server and syncs some data int SQLite
I have an Android app that uses the AlarmService. According to the docs, I
I have an SQLite query in my android app that seems to crash when

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.