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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T10:33:50+00:00 2026-05-30T10:33:50+00:00

I have created a new class called Get_WebPage1 and init I have extends that

  • 0

I have created a new class called Get_WebPage1 and init I have extends that class to use AsyncTask… as show below but still I get the same error:

public class Get_Webpage1 extends AsyncTask<String, Void, String> {

    public String parsing_url = "";

    public Get_Webpage1(String url_2_get){      
        parsing_url = url_2_get;
    }

    @Override
    protected String doInBackground(String... params) {
        // TODO Auto-generated method stub
        HttpClient client = new DefaultHttpClient();
        HttpGet request = new HttpGet(parsing_url);
        HttpResponse response = null;
        try {
            response = client.execute(request);
        } catch (ClientProtocolException e) {

        } catch (IOException e) {

        }

        String html = "";
        InputStream in = null;
        try {
            in = response.getEntity().getContent();
        } catch (IllegalStateException e) {

        } catch (IOException e) {

        }
        ....
                ....

        return html;
    }
}

Calling the class:

//Looper.myLooper().prepare(); 
         String url = "http://ofertaweb.ro/android/sleepandlovemusic/list_files.php";
         Get_Webpage1 obj = new Get_Webpage1(url);
         directory_listings = obj.doInBackground("test");//get_webpage_source();            songs_array = directory_listings.split(":::");

end update

I am trying to read the .htm file through website and it was working without any issues but suddenly I started getting this error message: and spend time googling but no avail..

AndroidRuntime(5715): java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare()

Here is my code:

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

        setContentView(R.layout.main);
        m_orders = new ArrayList<Order>();
        this.m_adapter = new OrderAdapter(this, R.layout.row, m_orders);
        setListAdapter(this.m_adapter);       

        selelctedFile = (TextView)findViewById(R.id.selectedfile);
        seekbar = (SeekBar)findViewById(R.id.seekbar);
        playButton = (ImageButton)findViewById(R.id.play);
        prevButton = (ImageButton)findViewById(R.id.prev);
        nextButton = (ImageButton)findViewById(R.id.next);


        player = new MediaPlayer();

        playButton.setOnClickListener(onButtonClick);
        nextButton.setOnClickListener(onButtonClick);
        prevButton.setOnClickListener(onButtonClick);

        viewOrders = new Runnable(){            
            public void run() {
                loadList();
                getOrders();
            }
        };

        Thread thread =  new Thread(null, viewOrders, "MagentoBackground");
        thread.start();
        m_ProgressDialog = ProgressDialog.show(this, "Please wait...", "Retrieving data ...", true);
    }

//here is what I am going to internet and reading the .htm page:

private void loadList(){

try 
  { 
     //Looper.myLooper().prepare(); 
     String url = "http://ofertaweb.ro/android/sleepandlovemusic/list_files.php";
     Get_Webpage obj = new Get_Webpage(url);
     directory_listings = obj.get_webpage_source(); //
     songs_array = directory_listings.split(":::");

   } 
   catch (Exception e) {
      Toast.makeText(
    this, "You have to be connected to the internet for this application to work" +   e.getMessage(),   Toast.LENGTH_LONG).show();
   finish();
  } 
}

error stack:

02-24 00:02:25.507: E/AndroidRuntime(5715): FATAL EXCEPTION: MagentoBackground
02-24 00:02:25.507: E/AndroidRuntime(5715): java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare()
02-24 00:02:25.507: E/AndroidRuntime(5715):     at android.os.Handler.<init>(Handler.java:121)
02-24 00:02:25.507: E/AndroidRuntime(5715):     at android.widget.Toast.<init>(Toast.java:68)
02-24 00:02:25.507: E/AndroidRuntime(5715):     at android.widget.Toast.makeText(Toast.java:231)
02-24 00:02:25.507: E/AndroidRuntime(5715):     at com.softberries.sf.SoftwarePassionView.loadList(SoftwarePassionView.java:262)
02-24 00:02:25.507: E/AndroidRuntime(5715):     at com.softberries.sf.SoftwarePassionView.access$11(SoftwarePassionView.java:239)
02-24 00:02:25.507: E/AndroidRuntime(5715):     at com.softberries.sf.SoftwarePassionView$4.run(SoftwarePassionView.java:87)
02-24 00:02:25.507: E/AndroidRuntime(5715):     at java.lang.Thread.run(Thread.java:1019)
02-24 00:02:26.517: E/WindowManager(5715): Activity com.softberries.sf.SoftwarePassionView has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView@40526408 that was originally added here
02-24 00:02:26.517: E/WindowManager(5715): android.view.WindowLeaked: Activity com.softberries.sf.SoftwarePassionView has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView@40526408 that was originally added here
02-24 00:02:26.517: E/WindowManager(5715):  at android.view.ViewRoot.<init>(ViewRoot.java:258)
02-24 00:02:26.517: E/WindowManager(5715):  at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:148)
02-24 00:02:26.517: E/WindowManager(5715):  at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:91)
02-24 00:02:26.517: E/WindowManager(5715):  at android.view.Window$LocalWindowManager.addView(Window.java:424)
02-24 00:02:26.517: E/WindowManager(5715):  at android.app.Dialog.show(Dialog.java:241)
02-24 00:02:26.517: E/WindowManager(5715):  at android.app.ProgressDialog.show(ProgressDialog.java:107)
02-24 00:02:26.517: E/WindowManager(5715):  at android.app.ProgressDialog.show(ProgressDialog.java:90)
02-24 00:02:26.517: E/WindowManager(5715):  at com.softberries.sf.SoftwarePassionView.onCreate(SoftwarePassionView.java:94)
02-24 00:02:26.517: E/WindowManager(5715):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
02-24 00:02:26.517: E/WindowManager(5715):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
02-24 00:02:26.517: E/WindowManager(5715):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
02-24 00:02:26.517: E/WindowManager(5715):  at android.app.ActivityThread.access$1500(ActivityThread.java:117)
02-24 00:02:26.517: E/WindowManager(5715):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
02-24 00:02:26.517: E/WindowManager(5715):  at android.os.Handler.dispatchMessage(Handler.java:99)
02-24 00:02:26.517: E/WindowManager(5715):  at android.os.Looper.loop(Looper.java:123)
02-24 00:02:26.517: E/WindowManager(5715):  at android.app.ActivityThread.main(ActivityThread.java:3683)
02-24 00:02:26.517: E/WindowManager(5715):  at java.lang.reflect.Method.invokeNative(Native Method)
02-24 00:02:26.517: E/WindowManager(5715):  at java.lang.reflect.Method.invoke(Method.java:507)
02-24 00:02:26.517: E/WindowManager(5715):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
02-24 00:02:26.517: E/WindowManager(5715):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
  • 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-30T10:33:51+00:00Added an answer on May 30, 2026 at 10:33 am

    I suggest you to use AsyncTask for this. Do the loadList in doInBackground and upload UI in onPostExecute.
    This problem usually because you do something with UI in the thread. E.g Displaying a Toast

    Android AsyncTask

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

Sidebar

Related Questions

I have created a class called SimpleCanvas which extends the JPanel class, and I
I am new to iphone development.I have created a UIview controller class and added
We have created a new List View Style that shows thumbnails from a picture
I have created a new solution with a minimal amount of code that represents
I have created a new method in one of the project's controllers that it
I have created a new ActionFilter for an ASP.NET MVC application that I'm creating.
I m new to use ankhSVN and having issues. I have created some new
My app has a singleton class called CycleManager. I have created a sealed class
I have created a new migration: class AddSignatureToUser < ActiveRecord::Migration def self.up add_column :users,
I have created a class called BasePage which inherits System.Web.UI.Page. On this page I've

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.