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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T02:36:11+00:00 2026-05-31T02:36:11+00:00

I have a PreferenceActivity that gets its data from a web service(Call forward Numbers,

  • 0

I have a PreferenceActivity that gets its data from a web service(Call forward Numbers, Voicemail status etc)

The class looks like this :

public class SettingsActivity extends PreferenceActivity
{
UserController userControl;
ListPreference lp;
public SharedPreferences prefs;
@Override
public void onCreate(Bundle savedInstanceState)
{
    super.onCreate(savedInstanceState);
    userControl = new UserController(getParent());
    addPreferencesFromResource(R.layout.settings);

    new PullNumbersTask().execute();

}

   private class PullNumbersTask extends AsyncTask<Void, Void, String[]>
{
    private ProgressDialog Dialog;
    private String[] numbers;
    private boolean vmStatus;
    private String[] cfInfo;
    public PullNumbersTask()
    {
         Dialog = new ProgressDialog(getParent());
         Dialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
    }


    protected void onPreExecute() 
    {
        Dialog.setMessage("Henter brugerindstillinger..");
        Dialog.show();
    }

    @Override
    protected String[] doInBackground(Void... arg0) 
    {
        numbers = userControl.GetNumbers(); // Returns a String array containing available numbers
        Dialog.setProgress(30);
        vmStatus = userControl.GetVoicemailStatus(); // Returns a boolean containing voicemail status(enabled/disabled)
        Dialog.setProgress(80);
        cfInfo = userControl.GetCallForwardInfo(); // Returns a String array containing Call forward info.
        Dialog.setProgress(100);

        return null;
    }



     protected void onPostExecute(String[] result) 
     {
        lp = (ListPreference) findPreference("shownumber_list");
        lp.setEntries(result);
        lp.setEntryValues(result);
        Dialog.dismiss();
     }

}

I decided that I want a single AsyncTask call to perform all my web service calls – But how do I Set the data of my preferences onPostExecute?

  • 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-31T02:36:12+00:00Added an answer on May 31, 2026 at 2:36 am

    Instead of using a String[] as return value from the doInBackground() method, define a class inside your AyncTask with the fields you need to be passed to the onPostExecute() method.

    Moreover you should avoid updating the progress dialog directly from the doInBackground() as it will not be performed in the UI thread. The AsynClass provides the possibility to pass a parameter to a onProgressUpdate() method to reflect changes in the progress of background execution.

    More details here: http://developer.android.com/reference/android/os/AsyncTask.html

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

Sidebar

Related Questions

I have a PreferenceActivity that loads its preferences from an XML file which looks
I have an application that uses the new features of honeycomb for the PreferenceActivity.
I have this widget in android, that displays an image and gets updated periodically
I have a PreferenceActivity that loads two Fragments via the xml file for the
I have the following ListPreference in a PreferenceActivity that I wish to populate with
I have an .apk that has a Service and an Activity that I want
I have a class that extends PreferenceActivity and shows the preference screen of my
I have a menu that comes up for my PreferenceActivity. In my child preference
I'm using PreferenceActivity to set some preferences about another BroadcastReciever that i have. While
I have a PreferenceActivity that contains a RingtonePrefernce built in xml along with other

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.