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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T07:24:31+00:00 2026-06-04T07:24:31+00:00

I am having a problem with an Android program I’m working on. The method

  • 0

I am having a problem with an Android program I’m working on. The method below is in MyActivity. MyActivity has an inner class InnerClass which extends AsyncTask. In the doInBackground method of InnerClass i search a database. The result of that search is passed to this method processSearchResult. Everything works except the very last line throws a NullPointerException. I tried using getApplicationContext() in place of this while creating the button and it still threw the exception. I debugged it and found the problem is in the android.content.ContextWrapper class. In the getApplicationContext() method is a call mBase.getApplicationContext. The problem is that the variable mBase is null. When using the this keyword there is still a call to this method and mBase is still null. Can anyone tell me why mBase is null? Or if its actually normal for mBase to be null?

public void processSearchResult(ResultSet result) {
    try {

    int x = 1;
    while (result.next()) {

        String name = result.getString(1);
        String ing = result.getString(2);
        String ins = result.getString(3);
        String notes = result.getString(4);
        String type = result.getString(5);
        String course = result.getString(6);

        Recipe r = new Recipe(name, ing, ins, notes, type, course);
        recipeList.add(r);

        Button button = new Button(this);
  • 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-04T07:24:32+00:00Added an answer on June 4, 2026 at 7:24 am

    You can’t update the user interface from the doInBackground method of the AsyncTask you need to publishProgress and update it from the onProgressUpdate method instead.

    How do I publish my progress from doInBackground

    publishProgress(0); //Assuming progress is 0
    

    Where do I update the UI from then?

    @Override
    protected void onProgressUpdate(Integer... progress){
        //HERE
    }
    

    this may not refer to what you’re thinking.
    What I do is keep a private global Context variable in my code for future reference as in:

    private Context x = this; 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having a problem with my android program. I have about every thing working
I'm having trouble putting this problem into searchable terms. I'm working on an Android
I am having another problem with my android app which I can't find an
I'm having a problem with an android application that I'm working on. My application
I'm having a strange problem with Android 1.6 I have an application that has
On Android, I'm having a problem trying to figure out which ringtone is actually
I created a class extending CursorAdapter, i am having problem on the bindView method.
I'm having a problem with my android program and session cookies. The Session is
I am having a problem with views overlapping in a RelativeLayout on Android 1.5...
Possible Duplicate: Android Launch an application from another application I am having a problem

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.