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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T15:41:12+00:00 2026-06-02T15:41:12+00:00

I am trying to create a progress dialog in between two intents. Here is

  • 0

I am trying to create a progress dialog in between two intents. Here is the code:

        public class DissertationActivity extends ListActivity {
/** Called when the activity is first created. */

public ArrayList<String> book_Array = new ArrayList<String>();
ArrayAdapter<String> adapter;

String href = "";
String href1 = "";
String search_Word = "";

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    Bundle extras = getIntent().getExtras();
    search_Word = extras.getString("query1");

    adapter = new ArrayAdapter<String>(this, R.layout.list_item_1,
            book_Array);
    setListAdapter(adapter);

    new LoginProgressTask().execute();


}

class LoginProgressTask extends AsyncTask<String, Integer, String> {

    ProgressDialog pDialog = new ProgressDialog(DissertationActivity.this);


    protected void onPreExecute() {
        this.pDialog.setMessage("Progress start");
        this.pDialog.show();


    }


    @Override
    protected String doInBackground(String... params) {

        ListView lv = getListView();
        lv.setTextFilterEnabled(true);

        try {
            Document doc = null;
            Document guestLink = null;

            guestLink = Jsoup.connect("https://aulib.abdn.ac.uk:443/F")
                    .get();
            Element link = guestLink.select("p > a").first();
            href1 = link.attr("href");
            href = href1.substring(0, href1.length() - 2); // removes -0
                                                            // from
                                                            // the

            // href_Array.add(href); //adds href to the array because string
            // wont add to the public var.
            doc = Jsoup.connect(
                    href + "&request=" + search_Word
                            + "&find_code=WRD&adjacent=N&x=0&y=0").get();
            // System.out.println(doc);
            Elements headings = doc.select("td:eq(3)");
            // System.out.println(headings);
            for (Element heading : headings) {
                // System.out.println(heading.text());
                String j = heading.text();

                book_Array.add(j);

            }

        } catch (IOException e) {
            e.printStackTrace();

        }

        book_Array.remove(0);
        adapter.notifyDataSetChanged();
        book_Array.remove(1);
        adapter.notifyDataSetChanged();
        book_Array.remove(2);
        adapter.notifyDataSetChanged();
        book_Array.remove("Search");
        adapter.notifyDataSetChanged();
        book_Array.remove(" | ");
        adapter.notifyDataSetChanged();
        book_Array.remove(0);
        adapter.notifyDataSetChanged();

        lv.setOnItemClickListener(new OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> a, View v, int position,
                    long id) {
                // Context context = getApplicationContext();
                int query = position;
                // String text = book_Array.get(position);
                // int duration = Toast.LENGTH_SHORT;
                // Toast toast = Toast.makeText(context,
                // String.valueOf(position), //shows the postion in the
                // array
                // list
                // duration);
                // toast.show();

                Intent intent = new Intent(DissertationActivity.this,
                FullDetailsActivity.class);
        intent.putExtra("href", href);
        intent.putExtra("query1", (int) query);
        intent.putExtra("search_Word", search_Word);

        startActivity(intent);
            }

        });
        return null;
    }


    protected void onPostExecute(String...params) {

        pDialog.dismiss();


}
      }}

04-23 17:45:16.752: E/AndroidRuntime(2425): FATAL EXCEPTION: AsyncTask #1
04-23 17:45:16.752: E/AndroidRuntime(2425): java.lang.RuntimeException: An error occured while executing doInBackground()
04-23 17:45:16.752: E/AndroidRuntime(2425): at android.os.AsyncTask$3.done(AsyncTask.java:200)
04-23 17:45:16.752: E/AndroidRuntime(2425): at java.util.concurrent.FutureTask$Sync.innerSetException(FutureTask.java:274)
04-23 17:45:16.752: E/AndroidRuntime(2425): at java.util.concurrent.FutureTask.setException(FutureTask.java:125)
04-23 17:45:16.752: E/AndroidRuntime(2425): at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:308)
04-23 17:45:16.752: E/AndroidRuntime(2425): at java.util.concurrent.FutureTask.run(FutureTask.java:138)
04-23 17:45:16.752: E/AndroidRuntime(2425): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1088)
04-23 17:45:16.752: E/AndroidRuntime(2425): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:581)
04-23 17:45:16.752: E/AndroidRuntime(2425): at java.lang.Thread.run(Thread.java:1019)
04-23 17:45:16.752: E/AndroidRuntime(2425): Caused by: android.view.ViewRoot$CalledFromWrongThreadException: Only the original thread that created a view hierarchy can touch its views.
04-23 17:45:16.752: E/AndroidRuntime(2425): at android.view.ViewRoot.checkThread(ViewRoot.java:2941)
04-23 17:45:16.752: E/AndroidRuntime(2425): at android.view.ViewRoot.focusableViewAvailable(ViewRoot.java:1717)
04-23 17:45:16.752: E/AndroidRuntime(2425): at android.view.ViewGroup.focusableViewAvailable(ViewGroup.java:452)
04-23 17:45:16.752: E/AndroidRuntime(2425): at android.view.ViewGroup.focusableViewAvailable(ViewGroup.java:452)
04-23 17:45:16.752: E/AndroidRuntime(2425): at android.view.ViewGroup.focusableViewAvailable(ViewGroup.java:452)
04-23 17:45:16.752: E/AndroidRuntime(2425): at android.view.View.setFlags(View.java:4631)
04-23 17:45:16.752: E/AndroidRuntime(2425): at android.view.View.setFocusableInTouchMode(View.java:3206)
04-23 17:45:16.752: E/AndroidRuntime(2425): at android.widget.AdapterView.checkFocus(AdapterView.java:694)
04-23 17:45:16.752: E/AndroidRuntime(2425): at android.widget.AdapterView$AdapterDataSetObserver.onChanged(AdapterView.java:789)
04-23 17:45:16.752: E/AndroidRuntime(2425): at android.database.DataSetObservable.notifyChanged(DataSetObservable.java:31)
04-23 17:45:16.752: E/AndroidRuntime(2425): at android.widget.BaseAdapter.notifyDataSetChanged(BaseAdapter.java:50)
04-23 17:45:16.752: E/AndroidRuntime(2425): at android.widget.ArrayAdapter.notifyDataSetChanged(ArrayAdapter.java:247)
04-23 17:45:16.752: E/AndroidRuntime(2425): at com.library_app.DissertationActivity$LoginProgressTask.doInBackground(DissertationActivity.java:103)
04-23 17:45:16.752: E/AndroidRuntime(2425): at com.library_app.DissertationActivity$LoginProgressTask.doInBackground(DissertationActivity.java:1)
04-23 17:45:16.752: E/AndroidRuntime(2425): at android.os.AsyncTask$2.call(AsyncTask.java:185)
04-23 17:45:16.752: E/AndroidRuntime(2425): at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:306)
04-23 17:45:16.752: E/AndroidRuntime(2425): … 4 more
04-23 17:45:16.902: E/WindowManager(2425): Activity com.library_app.DissertationActivity has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView@40666e70 that was originally added here
04-23 17:45:16.902: E/WindowManager(2425): android.view.WindowLeaked: Activity com.library_app.DissertationActivity has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView@40666e70 that was originally added here
04-23 17:45:16.902: E/WindowManager(2425): at android.view.ViewRoot.(ViewRoot.java:259)
04-23 17:45:16.902: E/WindowManager(2425): at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:148)
04-23 17:45:16.902: E/WindowManager(2425): at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:91)
04-23 17:45:16.902: E/WindowManager(2425): at android.view.Window$LocalWindowManager.addView(Window.java:465)
04-23 17:45:16.902: E/WindowManager(2425): at android.app.Dialog.show(Dialog.java:241)
04-23 17:45:16.902: E/WindowManager(2425): at com.library_app.DissertationActivity$LoginProgressTask.onPreExecute(DissertationActivity.java:59)
04-23 17:45:16.902: E/WindowManager(2425): at android.os.AsyncTask.execute(AsyncTask.java:391)
04-23 17:45:16.902: E/WindowManager(2425): at com.library_app.DissertationActivity.onCreate(DissertationActivity.java:49)
04-23 17:45:16.902: E/WindowManager(2425): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
04-23 17:45:16.902: E/WindowManager(2425): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1722)
04-23 17:45:16.902: E/WindowManager(2425): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1784)
04-23 17:45:16.902: E/WindowManager(2425): at android.app.ActivityThread.access$1500(ActivityThread.java:123)
04-23 17:45:16.902: E/WindowManager(2425): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:939)
04-23 17:45:16.902: E/WindowManager(2425): at android.os.Handler.dispatchMessage(Handler.java:99)
04-23 17:45:16.902: E/WindowManager(2425): at android.os.Looper.loop(Looper.java:130)
04-23 17:45:16.902: E/WindowManager(2425): at android.app.ActivityThread.main(ActivityThread.java:3835)
04-23 17:45:16.902: E/WindowManager(2425): at java.lang.reflect.Method.invokeNative(Native Method)
04-23 17:45:16.902: E/WindowManager(2425): at java.lang.reflect.Method.invoke(Method.java:507)
04-23 17:45:16.902: E/WindowManager(2425): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:847)
04-23 17:45:16.902: E/WindowManager(2425): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:605)
04-23 17:45:16.902: E/WindowManager(2425): at dalvik.system.NativeStart.main(Native Method)
[sorry don’t know how to indent this]

The progress bar manages to load but the code crashes after a few seconds. Where should the intents be, in the doInBackground or in postExecute? If the intents are meant to be in postExecte how would I pass the variables from doInBackground to postExecute?

What is wrong with the code and what needs to be changed so that it doesn’t crash anymore?

  • 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-02T15:41:14+00:00Added an answer on June 2, 2026 at 3:41 pm

    You can update UI in doInBackGround()

    Seeing you log trace, I can tell that you are trying to update UI in doInBackGround which you cannot do directly instead call runOnUiThread method and everything will be fine…
    Use

    YourActivity.this.runOnUiThread(new Runnable() {                                            
    public void run() {
     ListView lv = getListView();
     lv.setTextFilterEnabled(true);
     // do all UI related stuff in this
    }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to create downloading progress. I have my class which extends AsyncTask:
private class DownloadLargeFileTask extends AsyncTask<Void, Void, Void> { private final ProgressDialog dialog; public DownloadLargeFileTask(ProgressDialog
I'm trying to create a dialog window using JQuery. I'm making progress so far,
I'm trying to create a simple app for android with progress bar . Everything
I am trying to find the best option to create a simple progress bar
Ok so I am trying create a login script, here I am using PHP5
I am trying to create a ListActivity which its rows contain a text and
I'm trying to show a progress dialog while loading information from the web that
I am trying to add a progress dialog when a new activity is launched
I'm trying to do a search from my database here is the code it

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.