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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T00:35:07+00:00 2026-06-11T00:35:07+00:00

I am trying to make a new application and I would like to get

  • 0

I am trying to make a new application and I would like to get stock updates, currency exchange updates etc. I already tried Google Finance API. Reason for not using: Deprecated and to be closed soon which will make my application obsolete.

Then I moved on to Yahoo Finance and found http://learnandroidfast.blogspot.in/2012/02/yql-open-api.html.

Here is my code :

    /*
     * To convert the InputStream to String we use the
     * BufferedReader.readLine() method. We iterate until the BufferedReader
     * return null which means there's no more data to read. Each line will
     * appended to a StringBuilder and returned as String.
     */
private static String convertStreamToString(InputStream is) {
    BufferedReader reader = new BufferedReader(new InputStreamReader(is));
    StringBuilder sb = new StringBuilder();

    String line = null;
    try {
        while ((line = reader.readLine()) != null) {
            sb.append(line + "\n");
        }
    } catch (IOException e) {
        e.printStackTrace();
    } finally {
        try {
            is.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
    return sb.toString();
}

/*
 * This is a test function which will connects to a given rest service and
 * prints it's response to Android Log with labels "Praeda".
 */
public static String[] connect(String url) {
    HttpClient httpclient = new DefaultHttpClient();
    String[] str = new String[5];

    // Prepare a request object
    HttpGet httpget = new HttpGet(url);

    // Execute the request
    HttpResponse response;
    try {
        response = httpclient.execute(httpget);
        // Examine the response status
        Log.d(TAG, response.getStatusLine().toString());

        // Get hold of the response entity
        HttpEntity entity = response.getEntity();
        // If the response does not enclose an entity, there is no need
        // to worry about connection release

        if (entity != null) {

            // A Simple JSON Response Read
            InputStream instream = entity.getContent();
            String result = convertStreamToString(instream);
            Log.d(TAG, result);

            // A Simple JSONObject Creation
            JSONObject json = new JSONObject(result);
            Log.d(TAG, "<jsonobject>\n" + json.toString()
                    + "\n</jsonobject>");

            // A Simple JSONObject Parsing
            // JSONArray nameArray=json.names();
            // Log.i("query",nameArray.toString());
            // JSONObject query=json.getJSONObject("query");
            // Log.i("query",query.toString());
            // JSONArray results=query.getJSONArray("results");
            // Log.i("rslts",results.toString());
            // JSONArray quote=results.getJSONArray("quote");
            // JSONObject quote=results.getJSONObject("quote");
            // Log.i("quote",quote.toString());
            JSONObject query = json.getJSONObject("query");
            Log.d(TAG, query.toString());
            JSONObject results = query.getJSONObject("results");
            Log.d(TAG, results.toString());
            JSONObject quote = results.getJSONObject("quote");
            Log.d(TAG, quote.toString());
            for (int i = 0; i < quote.length(); i++) {

                // Log.i("Praedafor","<jsonname"+i+">\n"+nameArray.getString(i)+"\n</jsonname"+i+">\n"
                // +"<jsonvalue"+i+">\n"+valArray.getString(i)+"\n</jsonvalue"+i+">");
                // JSONObject quotes = results.getJSONObject(i)
                // .getJSONObject("quote");
                // Log,i
                // Log.i("name",quote.getString("Name"));
                // Log.i("name","pahunch");
                // Log.i("name",quote.getString("Symbol"));

                // Log.i("name",quote.getString("DaysLow"));

                // Log.i("name",quote.getString("DaysHigh"));

                // Log.i("name",quote.getString("Open"));

                // Log.i("name",quote.getString("PreviousClose"));
                String symbol = quote.getString("Symbol");
                str[0] = symbol;
                String dayslow = quote.getString("DaysLow");
                str[1]=dayslow;
                // tv1.setText(quote.getString("DaysLow"));
                str[2]= quote.getString("DaysHigh");
                str[3]= quote.getString("Open");
                str[4]= quote.getString("Change");
            }

            // A Simple JSONObject Value Pushing
            // json.put("execution-start-time", "sample value");
            Log.d(TAG, "<jsonobject>\n" + json.toString()
                    + "\n</jsonobject>");
            // Log.i("Praeda12",json.get("").toString());

            // Closing the input stream will trigger connection release
            instream.close();
        }

    } catch (ClientProtocolException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (JSONException e) {
        // TODO Auto-generated catch block
        e.getMessage();
    }
    return str;
}

`
I am calling it :

RestClient.connect("http://finance.yahoo.com/webservice/v1/symbols/allcurrencies/quote");

I am gettnig following exception :

`09-07 00:00:26.675: W/System.err(469): java.net.UnknownHostException: finance.yahoo.com
09-07 00:00:26.755: W/System.err(469):  at java.net.InetAddress.lookupHostByName(InetAddress.java:513)
09-07 00:00:26.755: W/System.err(469):  at java.net.InetAddress.getAllByNameImpl(InetAddress.java:278)
09-07 00:00:26.755: W/System.err(469):  at java.net.InetAddress.getAllByName(InetAddress.java:242)
09-07 00:00:26.755: W/System.err(469):  at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:136)
09-07 00:00:26.755: W/System.err(469):  at org.apache.http.impl.conn.AbstractPoolEntry.open(AbstractPoolEntry.java:164)
09-07 00:00:26.755: W/System.err(469):  at org.apache.http.impl.conn.AbstractPooledConnAdapter.open(AbstractPooledConnAdapter.java:119)
09-07 00:00:26.765: W/System.err(469):  at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:348)
09-07 00:00:26.765: W/System.err(469):  at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:555)
09-07 00:00:26.765: W/System.err(469):  at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:487)
09-07 00:00:26.765: W/System.err(469):  at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:465)
09-07 00:00:26.765: W/System.err(469):  at RestClient.connect(RestClient.java:65)
09-07 00:00:26.765: W/System.err(469):  at ExchangeUpdateService.buildUpdate(ExchangeUpdateService.java:43)
09-07 00:00:26.765: W/System.err(469):  at ExchangeUpdateService.onStart(ExchangeUpdateService.java:31)
09-07 00:00:26.765: W/System.err(469):  at android.app.Service.onStartCommand(Service.java:420)
09-07 00:00:26.765: W/System.err(469):  at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:3059)
09-07 00:00:26.765: W/System.err(469):  at android.app.ActivityThread.access$3600(ActivityThread.java:126)
09-07 00:00:26.765: W/System.err(469):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2101)
09-07 00:00:26.765: W/System.err(469):  at android.os.Handler.dispatchMessage(Handler.java:99)
09-07 00:00:26.765: W/System.err(469):  at android.os.Looper.loop(Looper.java:123)
09-07 00:00:26.765: W/System.err(469):  at 
android.app.ActivityThread.main(ActivityThread.java:4633)
09-07 00:00:26.765: W/System.err(469):  at java.lang.reflect.Method.invokeNative(Native Method)
09-07 00:00:26.765: W/System.err(469):  at java.lang.reflect.Method.invoke(Method.java:521)
09-07 00:00:26.765: W/System.err(469):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:858)
09-07 00:00:26.765: W/System.err(469):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
09-07 00:00:26.765: W/System.err(469):  at dalvik.system.NativeStart.main(Native Method)`

Please help.

  • 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-11T00:35:08+00:00Added an answer on June 11, 2026 at 12:35 am

    As it turns out there were two problems

    1. Internet permission not mentioned in manifest file.
    2. URL passed was incorrect.
      It should have been:

    "http://query.yahooapis.com/v1/public/yql?q=select%20rate%2Cname%20from%20csv%20where%20url%3D'http%3A%2F%2Fdownload.finance.yahoo.com%2Fd%2Fquotes%3Fs%3D"
    + from
    + to
    + "%253DX%26f%3Dl1n'%20and%20columns%3D'rate%2Cname'&format=json&callback=parseExchangeRate"

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

Sidebar

Related Questions

I am trying to make a new application and I would like to get
I'm trying to make a new wx.Choice-like control (actually a replacement for wx.Choice) which
I am trying to take a screenshot of an application and I would like
I'm trying to get a legacy MFC application and a new WPF usercontrol to
I'm trying to make an application (or webservice) hosted on IIS 6 that would
I am creating a new Rails 3.1 application. I would like this new application
I'm new to database applications and I'm trying to use Datamapper to make a
I am trying to make a new file format for music. It needs to
I'm trying to make a new CLLocation subclass. This is the skeleton: #import <UIKit/UIKit.h>
I work for a company and am trying to make a new demo page.

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.