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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T06:13:48+00:00 2026-05-26T06:13:48+00:00

The code at the bottom of this post is triggered by the following line

  • 0

The code at the bottom of this post is triggered by the following line of code.

new MasterClickAsyncTask(main).execute(position);

The doInBackground portion of code below calls a method containing a for loop, hence the need for Looper.prepare().

This code runs fine the first few times it is called but then it throws the following error:

10-15 22:50:24.752: ERROR/AndroidRuntime(9258): Caused by: java.lang.RuntimeException: Only one Looper may be created per thread

I’ve tried putting Looper.getMainLooper().quit(); and a few other things like this in various parts of the AsyncTask but this has only made it crash immediately.

Any Help?

Code:

import java.io.IOException;
import java.net.MalformedURLException;
import org.json.JSONException;
import android.os.AsyncTask;
import android.os.Looper;
import android.view.View;

public class MasterClickAsyncTask extends AsyncTask<Integer, Void, Void> {

    Master selectedMaster;
Main main;
MasterGridView masterGridView;
Integer i;
DiscogProxy discogProxy = new DiscogProxy();

MasterClickAsyncTask(Main main){
    this.main = main;
    this.masterGridView = main.getMasterGridView();
}

@Override
    protected void onPreExecute() {
        main.progressBar.setVisibility(View.VISIBLE);
    }
       @Override
        protected Void doInBackground(Integer... params) {
            masterGridView.getSelectedView();
            Globals.selectedMaster = (Master)(masterGridView).getItemAtPosition(params[0].intValue());
            Globals.selectedMaster.getVersionListView().getVersionList().clear();
               Looper.prepare();
              try {
                  Globals.selectedMaster.getVersionListView().populateVersionList();
                } catch (MalformedURLException e) {
                    e.printStackTrace();
                } catch (JSONException e) {
                    e.printStackTrace();
                } catch (IOException e) {
                    e.printStackTrace();
                }
               //Looper.getMainLooper().quit();
        return null;    
        }       

@Override
protected void onPostExecute(Void result) {
     main.populateAlbumVersionsView();
     main.progressBar.setVisibility(View.GONE);
}   
}
  • 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-26T06:13:49+00:00Added an answer on May 26, 2026 at 6:13 am

    Looper has nothing to do with for loops. The Looper is the part of the Android system that controls the UI thread. There are several things that wont work without preparing the looper, but in general it is best to avoid Looper.prepare(); unless absolutely necessary. It is far better to use the async doInBackground to perform data processing or other longer operations, and then update the UI with onPostExecute and onProgressUpdate.

    In short, unless you are using the UI in some way, you don’t need to call the Looper. If you find yourself having to call the Looper, you probably need to restructure how your background threads are working.

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

Sidebar

Related Questions

I have the following code: ul.post, ul.user_profile { /* this attributes are the same
SEE BOTTOM OF THIS POST FOR UPDATE ON THIS PLEASE. I have the below
This code should i place this code at bottom of body it's in conditional
This is the code. I want to align text at bottom <p style=background:#eee;font-size:1.3em;color:#022662;height:116px> <img
I added the solution to the code below. The code at the bottom is
EDITED SO THE CODE IS CORRECT (THANKS TO ta.speot.is) - NEW QUESTION AT BOTTOM
I am using the following code function xhi(aax) { var aby=document.getElementById(aax); aby.style.bottom=(parseInt(aby.style.bottom)+(screen.height-42)/10)+'px'; if(parseInt(aby.style.bottom)<(screen.height-42))setTimeout('xhi('+aax+')',25); }
I'll keep it simple: The code listed at the end of this post is
Scroll down to the bottom of this post to see a work around /
(code below regarding my question) Per this stack overflow question I used Pegolon's approach

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.