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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T08:41:06+00:00 2026-05-20T08:41:06+00:00

I have an asynctask of which’s onPostExecute i am calling a function to show

  • 0

I have an asynctask of which’s onPostExecute i am calling a function to show a customDialog.

This is my AsyncTask

private class DBTask extends AsyncTask<Long, Boolean, Integer>{ 
ProgressDialog ServerPD = new ProgressDialog(MRRankingActivity.this); 

@Override
protected void onPreExecute() 
{
    ServerPD = ProgressDialog.show (MRRankingActivity.this, "", "Connecting to server...", true, false);
}//End of onPreExecute

@Override
protected Integer doInBackground(Long... params) 
{
    int isSuccess=0;
    publishProgress(isOnline());

        if(isOnline())
        {

        getDBData();
                if(isOK)
                    {
                    isSuccess=1;
                    }
        }   
    }

    return isSuccess;
}

    @Override
protected void onProgressUpdate(Boolean... isConnection) {
// TODO Auto-generated method stub

super.onProgressUpdate(isConnection);
if(isOnline())
        {   
        ServerPD.setMessage("Retreving Data");
        }
}

@Override
protected void onPostExecute(Integer result) {
    if (ServerPD.isShowing())
    {
        ServerPD.dismiss(); 
    }
    if(result==1)
        {
            customDialog();
        }

}//End of onPostExecute

}//End of DBTask

And this is my customDialog function

public void customDialog(){
    Dialog dialog=new Dialog(MRRankingActivity.this);
    dialog.requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
    dialog.getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE,R.string.app_name );
    dialog.setContentView(R.layout.result_dialog);
    final ListView ResultView = (ListView) findViewById( R.id.ListResult );

    result_Adapter=new ArrayAdapter<String>(MRRankingActivity.this,android.R.layout.simple_list_item_1,result_Array);

    //Bind Array Adapter to ListView
    ResultView.setAdapter(result_Adapter);
    dialog.show();

}//end of custom dialog function

This is my result_dialog.xml

<?xml version="1.0" encoding="utf-8"?>
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content">

        <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_height="fill_parent" 
        android:layout_width="fill_parent"
        android:orientation="vertical">

            <ListView android:id="@+id/ListResult"
                android:layout_height="wrap_content"
                android:layout_width="fill_parent"/>

        </LinearLayout>

</RelativeLayout>

Now when i run this code i am getting this error

FATAL EXCEPTION: main
java.lang.NullPointerException

at com.lalsoft.mobileranking.MRRankingActivity.customDialog(MRRankingActivity.java)
at com.lalsoft.mobileranking.MRRankingActivity$DBTask.onPostExecute(MRRankingActivity.java)       at com.lalsoft.mobileranking.MRRankingActivity$DBTask.onPostExecute(MRRankingActivity.java)
at android.os.AsyncTask.finish(AsyncTask.java)
at android.os.AsyncTask.access$300(AsyncTask.java)
at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java)
at android.os.Handler.dispatchMessage(Handler.java)
at android.os.Looper.loop(Looper.java)
at android.app.ActivityThread.main(ActivityThread.java)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java)

If i comment

 //ResultView.setAdapter(result_Adapter);

in my customDialog function,the customDialog will show,without the Listview. This error is coming when i set the adapter to my ListView.

How to solve this issue??What should be done?? 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-05-20T08:41:07+00:00Added an answer on May 20, 2026 at 8:41 am

    Replace this line final ListView ResultView = (ListView)dialog.findViewById( R.id.ListResult );

    instead of final ListView ResultView = (ListView)findViewById( R.id.ListResult );

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

Sidebar

Related Questions

I have a common class say for eg Class A which extends AsyncTask and
I have a service, that requests another class, which launches an AsyncTask Service->Weather Class->Execute
this is the current state/situation: I have an Activity which binds a Service which
I have to download a file and I'm using this code , which is
I have a very strange problem. I have an AsyncTask which appears to block
I have a function which can vary in the time it takes to finish.
Have just started using Visual Studio Professional's built-in unit testing features, which as I
Have you managed to get Aptana Studio debugging to work? I tried following this,
I have a class that fetches data in response to button presses in the
I have one of my activities which I would like to prevent from rotating

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.