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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T06:06:58+00:00 2026-05-28T06:06:58+00:00

This is my code. When I click on my app logo, after the splash

  • 0

This is my code. When I click on my app logo, after the splash screen, this is the class that is first called from an intent. But, after the tab is loaded, and onPreExecute() is once executed, the app crashes.

public class HomeActivity extends Activity{
    private static final String dialog = null;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.user_main_tab_home);

        new HomeDownloadPage().execute();
    }


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

        private final ProgressDialog dialog = new ProgressDialog(HomeActivity.this);




         protected void onPreExecute() {
             this.dialog.setMessage("Have Paitence! ");
             this.dialog.show();


          }

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

                User user = null;

                 try {


                        user = new User("4eeb");
                        user.getList();

                        /*
                         * Custom adapter
                         * */
                        ArrayList<User> users = new ArrayList<User>();

                        for(User u : user.following){
                            users.add(u);
                        }

                        ListView lv = (ListView) findViewById(R.id.user_list);

                        final UserFollowingListAdapter csl = new UserFollowingListAdapter(HomeActivity.this,R.layout.user_list,users,this);


                        OnItemClickListener listener = new OnItemClickListener() {

                            public void onItemClick(AdapterView<?> parent, View view, int position,long id) {

                            Object o = csl.getItem(position);


                            setTitle(parent.getItemAtPosition(position).toString());
                            }
                          };

                          lv.setAdapter(csl);


                          lv.setOnItemClickListener(listener);


                          /*
                           * Onclick listener
                           * */     
                          lv.setOnItemClickListener(new OnItemClickListener() {
                                        @Override
                                        public void onItemClick(AdapterView<?> parent, View view,int position, long id) {
                                            Intent i = new Intent("com.list.SEARCH");
                                            Toast.makeText(HomeActivity.this, "rowitem clicked", Toast.LENGTH_LONG).show();
                                            // TODO Auto-generated method stub

                                        }
                                    });

                        } catch (Exception e) {

                                showError();
                        }
                return null;
            }

         protected void onPostExecute(String result) {
                // execution of result of Long time consuming operation

              }

    }

                public void showError(){
                    new AlertDialog.Builder(HomeActivity.this)
                    .setTitle(" Oops , Server down :( ")
                    .setPositiveButton("Ok", new DialogInterface.OnClickListener() {

                        @Override
                        public void onClick(DialogInterface arg0, int arg1) {
                            // TODO Auto-generated method stub

                        }
                        //
                    }).setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialog, int whichButton) {
                            // Do nothing.
                        }
                    }).show();

                }




        }

Error I get is at the doInBackground() function.

Exact error: 01-19 19:03:01.264: E/AndroidRuntime(1138): Caused by: java.lang.RuntimeException: Can’t create handler inside thread that has not called Looper.prepare()

What is the problem?

  • 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-28T06:06:59+00:00Added an answer on May 28, 2026 at 6:06 am

    You are attempting to do things involving the UI (ListView lv = (ListView) findViewById(R.id.user_list);) within a background thread. You can not do this. You may process information in the background, then pass it back to the UI thread and update the UI

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

Sidebar

Related Questions

I have this code in a button click for ratting this app -(IBAction)_clickbtnratethisApp:(id)sender {
This code has no errors in it, but when i click the button nothing
I wrote this code in order to make a soundboard like app public class
so when i run this code and click the button: from Tkinter import *
I have this code $(.delete2).click(function() { $('#load2').fadeIn(); } I have dynamically added item via
This code: $(#permalink a).click(function(id){ var id = this.getAttribute('href'); $(#newPostContent).load(id, function() { $(#removeTrigger).click(function() { $(#removeThis).hideToggle();
I have this code in jquery : $(#order_btn).click(function(){ var totalprice = $(.price_amount).text(); $(#totalprice).val(totalprice); });
I have this code: $('.user_info').click(function(){ var pos = $(this).offset(); rel_value = $(this).attr('rel'); $('#' +
I've got this code in a pair of button click event handlers on a
I have this code in the end of link button click: Response.ContentType = application/zip;

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.