title: AndroidRuntime: java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare()
body: <p>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:</p>
  
  <pre><code>public class Get_Webpage1 extends AsyncTask&lt;String, Void, String&gt; {
  
      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;
      }
  }
  </code></pre>
  
  <p>Calling the class:</p>
  
  <pre><code>//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(":::");
  </code></pre>
  
  <p><strong>end update</strong></p>
  
  <p>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..</p>
  
  <p><code>AndroidRuntime(5715): java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare()</code></p>
  
  <p>Here is my code:</p>
  
  <pre><code>@Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);   
  
          setContentView(R.layout.main);
          m_orders = new ArrayList&lt;Order&gt;();
          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);
      }
  </code></pre>
  
  <p>//here is what I am going to internet and reading the .htm page:</p>
  
  <pre><code>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();
    } 
  }
  </code></pre>
  
  <p>error stack:</p>
  
  <pre><code>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.&lt;init&gt;(Handler.java:121)
  02-24 00:02:25.507: E/AndroidRuntime(5715):     at android.widget.Toast.&lt;init&gt;(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.&lt;init&gt;(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)
  </code></pre>