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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T23:49:09+00:00 2026-05-30T23:49:09+00:00

try { Get_Webpage obj = new Get_Webpage(url); directory_listings = obj.get_webpage_source(); } catch (Exception e)

  • 0
try {
    Get_Webpage obj = new Get_Webpage(url);
    directory_listings = obj.get_webpage_source();
} catch (Exception e) {
    finish();
    m_ProgressDialog.dismiss();
    Toast.makeText(this, "You have to be connected to the internet for this application to work", Toast.LENGTH_LONG).show();
}


02-28 22:23:21.055: E/AndroidRuntime(2170): FATAL EXCEPTION: AsyncTask #1
02-28 22:23:21.055: E/AndroidRuntime(2170): java.lang.RuntimeException: An error occured while executing doInBackground()
02-28 22:23:21.055: E/AndroidRuntime(2170):     at android.os.AsyncTask$3.done(AsyncTask.java:200)
02-28 22:23:21.055: E/AndroidRuntime(2170):     at java.util.concurrent.FutureTask$Sync.innerSetException(FutureTask.java:274)
02-28 22:23:21.055: E/AndroidRuntime(2170):     at java.util.concurrent.FutureTask.setException(FutureTask.java:125)
02-28 22:23:21.055: E/AndroidRuntime(2170):     at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:308)
02-28 22:23:21.055: E/AndroidRuntime(2170):     at java.util.concurrent.FutureTask.run(FutureTask.java:138)
02-28 22:23:21.055: E/AndroidRuntime(2170):     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1088)
02-28 22:23:21.055: E/AndroidRuntime(2170):     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:581)
02-28 22:23:21.055: E/AndroidRuntime(2170):     at java.lang.Thread.run(Thread.java:1019)
02-28 22:23:21.055: E/AndroidRuntime(2170): Caused by: java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare()
02-28 22:23:21.055: E/AndroidRuntime(2170):     at android.os.Handler.<init>(Handler.java:121)
02-28 22:23:21.055: E/AndroidRuntime(2170):     at android.widget.Toast.<init>(Toast.java:68)
02-28 22:23:21.055: E/AndroidRuntime(2170):     at android.widget.Toast.makeText(Toast.java:231)
02-28 22:23:21.055: E/AndroidRuntime(2170):     at net.website.qt.mediaplayer.Main.showToast(Main.java:414)
02-28 22:23:21.055: E/AndroidRuntime(2170):     at net.website.qt.mediaplayer.Main.access$15(Main.java:413)
02-28 22:23:21.055: E/AndroidRuntime(2170):     at net.website.qt.mediaplayer.Main$taskDoSomething.doInBackground(Main.java:199)
02-28 22:23:21.055: E/AndroidRuntime(2170):     at net.website.qt.mediaplayer.Main$taskDoSomething.doInBackground(Main.java:1)
02-28 22:23:21.055: E/AndroidRuntime(2170):     at android.os.AsyncTask$2.call(AsyncTask.java:185)
02-28 22:23:21.055: E/AndroidRuntime(2170):     at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:306)
02-28 22:23:21.055: E/AndroidRuntime(2170):     ... 4 more

Update

@Override 
protected void onPostExecute(List<Employee> result) 
{            
    m_Employee.clear();     
    m_Employee.addAll(result);   
    m_ProgressDialog.dismiss();
    m_adapter.notifyDataSetChanged();   
} 

I have this long processing task in a app

As I understand it, the method doInBackground in SwingWorker is not
supposed to do anything with the UI. However, what I do in there may
throw exceptions, which I would like to handle with error messages to the user.

how should i handle this?

private class taskDoSomething extends AsyncTask<Void, Void, List<Employee>> 
{ 

    @Override 
    protected List<Employee> doInBackground(Void... params) 
    { 
    String url = "http://ofertaweb.ro/android/sleepandlovemusic/list_files.php";

    try {
        Get_Webpage obj = new Get_Webpage(url);
        directory_listings = obj.get_webpage_source();
    } catch (Exception e) {
         Toast.makeText(this, "You have to be connected to the internet for this application to work", Toast.LENGTH_LONG).show();
       finish();
    }

UPDATE with logcat:

02-28 21:47:01.194: W/dalvikvm(1820): threadid=9: thread exiting with uncaught exception (group=0x40015560)
02-28 21:47:01.314: E/AndroidRuntime(1820): FATAL EXCEPTION: AsyncTask #1
02-28 21:47:01.314: E/AndroidRuntime(1820): java.lang.RuntimeException: An error occured while executing doInBackground()
02-28 21:47:01.314: E/AndroidRuntime(1820):     at android.os.AsyncTask$3.done(AsyncTask.java:200)
02-28 21:47:01.314: E/AndroidRuntime(1820):     at java.util.concurrent.FutureTask$Sync.innerSetException(FutureTask.java:274)
02-28 21:47:01.314: E/AndroidRuntime(1820):     at java.util.concurrent.FutureTask.setException(FutureTask.java:125)
02-28 21:47:01.314: E/AndroidRuntime(1820):     at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:308)
02-28 21:47:01.314: E/AndroidRuntime(1820):     at java.util.concurrent.FutureTask.run(FutureTask.java:138)
02-28 21:47:01.314: E/AndroidRuntime(1820):     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1088)
02-28 21:47:01.314: E/AndroidRuntime(1820):     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:581)
02-28 21:47:01.314: E/AndroidRuntime(1820):     at java.lang.Thread.run(Thread.java:1019)
02-28 21:47:01.314: E/AndroidRuntime(1820): Caused by: java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare()
02-28 21:47:01.314: E/AndroidRuntime(1820):     at android.os.Handler.<init>(Handler.java:121)
02-28 21:47:01.314: E/AndroidRuntime(1820):     at android.widget.Toast.<init>(Toast.java:68)
02-28 21:47:01.314: E/AndroidRuntime(1820):     at android.widget.Toast.makeText(Toast.java:231)
02-28 21:47:01.314: E/AndroidRuntime(1820):     at net.website.qt.mediaplayer.Main.showToast(Main.java:411)
02-28 21:47:01.314: E/AndroidRuntime(1820):     at net.website.qt.mediaplayer.Main.access$14(Main.java:410)
02-28 21:47:01.314: E/AndroidRuntime(1820):     at net.website.qt.mediaplayer.Main$taskDoSomething.doInBackground(Main.java:197)
02-28 21:47:01.314: E/AndroidRuntime(1820):     at net.website.qt.mediaplayer.Main$taskDoSomething.doInBackground(Main.java:1)
02-28 21:47:01.314: E/AndroidRuntime(1820):     at android.os.AsyncTask$2.call(AsyncTask.java:185)
02-28 21:47:01.314: E/AndroidRuntime(1820):     at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:306)
02-28 21:47:01.314: E/AndroidRuntime(1820):     ... 4 more
02-28 21:47:02.954: E/WindowManager(1820): Activity net.website.qt.mediaplayer.Main has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView@40525ae0 that was originally added here
02-28 21:47:02.954: E/WindowManager(1820): android.view.WindowLeaked: Activity net.website.qt.mediaplayer.Main has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView@40525ae0 that was originally added here
02-28 21:47:02.954: E/WindowManager(1820):  at android.view.ViewRoot.<init>(ViewRoot.java:258)
02-28 21:47:02.954: E/WindowManager(1820):  at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:148)
02-28 21:47:02.954: E/WindowManager(1820):  at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:91)
02-28 21:47:02.954: E/WindowManager(1820):  at android.view.Window$LocalWindowManager.addView(Window.java:424)
02-28 21:47:02.954: E/WindowManager(1820):  at android.app.Dialog.show(Dialog.java:241)
02-28 21:47:02.954: E/WindowManager(1820):  at android.app.ProgressDialog.show(ProgressDialog.java:107)
02-28 21:47:02.954: E/WindowManager(1820):  at android.app.ProgressDialog.show(ProgressDialog.java:90)
02-28 21:47:02.954: E/WindowManager(1820):  at net.website.qt.mediaplayer.Main.onCreate(Main.java:136)
02-28 21:47:02.954: E/WindowManager(1820):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
02-28 21:47:02.954: E/WindowManager(1820):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
02-28 21:47:02.954: E/WindowManager(1820):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
02-28 21:47:02.954: E/WindowManager(1820):  at android.app.ActivityThread.access$1500(ActivityThread.java:117)
02-28 21:47:02.954: E/WindowManager(1820):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
02-28 21:47:02.954: E/WindowManager(1820):  at android.os.Handler.dispatchMessage(Handler.java:99)
02-28 21:47:02.954: E/WindowManager(1820):  at android.os.Looper.loop(Looper.java:123)
02-28 21:47:02.954: E/WindowManager(1820):  at android.app.ActivityThread.main(ActivityThread.java:3683)
02-28 21:47:02.954: E/WindowManager(1820):  at java.lang.reflect.Method.invokeNative(Native Method)
02-28 21:47:02.954: E/WindowManager(1820):  at java.lang.reflect.Method.invoke(Method.java:507)
02-28 21:47:02.954: E/WindowManager(1820):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
02-28 21:47:02.954: E/WindowManager(1820):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
02-28 21:47:02.954: E/WindowManager(1820):  at dalvik.system.NativeStart.main(Native Method)

UPDATE END

  • 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-30T23:49:11+00:00Added an answer on May 30, 2026 at 11:49 pm

    The important message here is this:
    Activity net.website.qt.mediaplayer.Main has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView@40525ae0 that was originally added here

    This is a pretty common error and has been addressed several times on SO already:

    Activity has leaked window that was originally added

    Activity has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView@46368a28 that was originally added here

    I’m pretty sure the offending line is:

         Toast.makeText(this, "You have to be connected to the internet for this application to work", Toast.LENGTH_LONG).show();
    

    Toast.makeText takes a Context as its first argument and not an AsyncTask. In this case when you use this its pointing to the AsyncTask not to a Context which is causing the problem.

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

Sidebar

Related Questions

I try to get this following url using the downloadURL function as follows: http://www.ncbi.nlm.nih.gov/nuccore/27884304
I get this wired error only when I try to access the web page
I am try to get a URL from a one server and using that
I try get the mp3 flash player to work with my javascript on all
I try to get to a page straight from Bash at http://www.ocwconsortium.org/ . The
I try to get all WPF window controls collections. In other words i try
I try to get the name of executable name of all of my launched
I try to get the last modification date of a file: NSFileManager *fm =
When I try to get the eventinfo of a WPF 'rectangle', if the routedEvent
I face a problem when I try to get value from primary table in

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.