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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T05:23:02+00:00 2026-05-24T05:23:02+00:00

For some reason the onPreExecute isn’t being called. Code: protected void onPreExcecute() { hook.createDialog(ticker);

  • 0

For some reason the onPreExecute isn’t being called. Code:

protected void onPreExcecute() {
    hook.createDialog(ticker);
}

Entire class:

package com.evandarwin.finance;

import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;

import android.content.Context;
import android.os.AsyncTask;
import android.widget.Toast;
public class GetTicker extends AsyncTask<String, Integer, String>{
    private Context ctx;
    private String ticker;
    private SimpleFinanceActivity hook;

    public GetTicker(Context ctx, String ticker, SimpleFinanceActivity hook) {
        this.ctx = ctx;
        this.ticker = ticker.toUpperCase();
        this.hook = hook;
    }

    protected void onPreExcecute() {
        hook.createDialog(ticker);
    }

    @SuppressWarnings("unused")
    @Override
    protected String doInBackground(String... params) {
        try {
            URL url = new URL("http://finance.yahoo.com/d/quotes.csv?s="+ticker+"&f=a");

            HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection();

            urlConnection.setRequestMethod("GET");
            urlConnection.setDoOutput(true);

            urlConnection.connect();
            InputStream is = urlConnection.getInputStream();
            StringBuffer str = new StringBuffer();

            int bufferLength = 0; //used to store a temporary size of the buffer

            byte[] stream = new byte[1024];

            while ( (bufferLength = is.read(stream)) > 0 ) {
                str.append(stream);
            }

            return str.toString();
        } catch (MalformedURLException e) {
            e.printStackTrace();
        } catch (IOException e1) {
            e1.printStackTrace();
        }
        return null;
    }

    protected void onPostExecute(String result) {
        hook.destroyDialog();
        Toast.makeText(ctx, result, Toast.LENGTH_LONG).show();
    }
}

This is giving me a NullPointerException, I know I’ve had this problem before but I don’t remember what I did to fix it. Please help! 😛

Screenshot

  • 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-24T05:23:03+00:00Added an answer on May 24, 2026 at 5:23 am

    The reason the @Override is causing a problem in Eclipse (and the reason the method isn’t being called) is that you have made a typing error.

    You are calling it onPreExcecute (note the ‘c’ after the ‘x’ shouldn’t be there). Correct it to be onPreExecute and use @Override for that.

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

Sidebar

Related Questions

For some reason, my script isn't writing out the text after I remove the
For some reason my simple jquery bind event isn't working. The funny thing is
for some reason my event data isn't working correctly with jquery fullcalendar when I
For some reason, my following line of code is returning a 0. int bac
For some reason the following code is giving me an exception. <Application.Resources> <ResourceDictionary> <ResourceDictionary.MergedDictionaries>
For some reason the LoadContent method does not get called in my Components. For
For some reason, pthread_create isn't allowing me to pass a struct as an argument.
For some reason if I try to display data with the following code, I
For some reason, exceptions thrown in an __autoload function aren't being caught when trying
For some reason I never see this done. Is there a reason why not?

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.