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

The Archive Base Latest Questions

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

package com.crumbin.tabs; //java package import java.io.IOException; import java.util.ArrayList; import org.json.JSONException; import android.app.Activity; import android.app.AlertDialog;

  • 0
       package com.crumbin.tabs;

//java package
import java.io.IOException;
import java.util.ArrayList;

import org.json.JSONException;

import android.app.Activity;
import android.app.AlertDialog;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.os.AsyncTask;
import android.os.Bundle;
import android.widget.ListView;

import com.crumbin.main.R;
import com.crumbin.models.User;
import com.crumbin.utilities.UserFollowingListAdapter;


public class HomeActivity extends Activity{

     final ArrayList<User> users1 = new ArrayList<User>();  
     User user;
//  public ArrayList<User> users1 = new ArrayList<User>();
     private UserFollowingListAdapter csl;
        private ListView lv;
   @Override
  public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.user_main_tab_home);
      lv = (ListView) findViewById(R.id.user_crumbs_list); 

     // ListView lv = (ListView) findViewById(R.id.user_crumbs_list);








      AsyncLoader task = new AsyncLoader();
      task.execute();




      }



       private    class AsyncLoader extends AsyncTask<String,Void, String> {
               ProgressDialog dialog;

            @Override

            protected void onPreExecute(){
                 String pa = "helllo";
                   return;

            }

            @Override
            protected String doInBackground(String... pa) {
                String response = "";



                    try {

                      try {
                            user = new User("4eeb34c6d80e8f1214000000");
                            user.getFollowingCrumbsUpList();
                            for(User u : user.following){
                                users1.add(u);
                            }
                        } catch (IOException e) {
                            // TODO Auto-generated catch block
                            e.printStackTrace();
                        } catch (JSONException e) {
                            // TODO Auto-generated catch block
                            e.printStackTrace();
                        }








                    } catch (Exception e) {
                        e.printStackTrace();
                    }

            return response;
            }

            protected void onPostExecute(String result) {
                //dialog.dismiss();
                ListView lv = (ListView) findViewById(R.id.user_crumbs_list);

                final UserFollowingListAdapter csl = new UserFollowingListAdapter(HomeActivity.this,R.layout.user_crumbs_list_item,users1,this);
                    lv.setAdapter(csl);
                return;

            }





       }





      public void showError(){
       new AlertDialog.Builder(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:

02-04 13:11:34.596: E/AndroidRuntime(2464): FATAL EXCEPTION: main
02-04 13:11:34.596: E/AndroidRuntime(2464): java.lang.ClassCastException: com.crumbin.tabs.HomeActivity$AsyncLoader cannot be cast to android.app.Activity
02-04 13:11:34.596: E/AndroidRuntime(2464):     at com.crumbin.utilities.UserFollowingListAdapter.<init>(UserFollowingListAdapter.java:40)
02-04 13:11:34.596: E/AndroidRuntime(2464):     at com.crumbin.tabs.HomeActivity$AsyncLoader.onPostExecute(HomeActivity.java:106)
02-04 13:11:34.596: E/AndroidRuntime(2464):     at com.crumbin.tabs.HomeActivity$AsyncLoader.onPostExecute(HomeActivity.java:1)
02-04 13:11:34.596: E/AndroidRuntime(2464):     at android.os.AsyncTask.finish(AsyncTask.java:602)
02-04 13:11:34.596: E/AndroidRuntime(2464):     at android.os.AsyncTask.access$600(AsyncTask.java:156)
02-04 13:11:34.596: E/AndroidRuntime(2464):     at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:615)
02-04 13:11:34.596: E/AndroidRuntime(2464):     at android.os.Handler.dispatchMessage(Handler.java:99)
02-04 13:11:34.596: E/AndroidRuntime(2464):     at android.os.Looper.loop(Looper.java:137)
02-04 13:11:34.596: E/AndroidRuntime(2464):     at android.app.ActivityThread.main(ActivityThread.java:4424)
02-04 13:11:34.596: E/AndroidRuntime(2464):     at java.lang.reflect.Method.invokeNative(Native Method)
02-04 13:11:34.596: E/AndroidRuntime(2464):     at java.lang.reflect.Method.invoke(Method.java:511)
02-04 13:11:34.596: E/AndroidRuntime(2464):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
02-04 13:11:34.596: E/AndroidRuntime(2464):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
02-04 13:11:34.596: E/AndroidRuntime(2464):     at dalvik.system.NativeStart.main(Native Method)

No data is loading. The loop doesn’t even reach the OnpostExecute(). What might be the error? I’m not getting errors. Just that it is not even reaching that part.

What I want to do is this:

Just load the data into a list. That is about it. And still this is not working. The logic is fine. This works if I use it without AsyncTask. But, if I put the code in it, it doesn’t work.

  • 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-29T06:58:41+00:00Added an answer on May 29, 2026 at 6:58 am

    Your AsyncTask class should be outside the onCreate() not inside the onCreate().

         UserFollowingListAdapter csl;
    
         @Override
          public void onCreate(Bundle savedInstanceState) {
              super.onCreate(savedInstanceState);
              setContentView(R.layout.user_main_tab_home);
              .............
              ListView lv = (ListView) findViewById(R.id.user_crumbs_list);
    
              csl = new UserFollowingListAdapter(HomeActivity.this,
                                       R.layout.user_crumbs_list_item,users1,this);
              lv.setAdapter(csl);
              new AsyncLoader().execute(user);  
         }
     class AsyncLoader extends AsyncTask<User,Void, String> {
    
        ..................
        protected void onPostExecute(String result) {
           csl.notifyDataSetChanged(); // refresh your ListView
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

package com.crumbin.tabs; import java.util.ArrayList; import java.util.HashMap; import org.apache.http.client.HttpClient; import android.content.Context; import android.database.Cursor; import android.location.Location;
package com.VRG; import java.io.IOException; import java.util.ArrayList; import java.util.HashMap; import android.app.Activity; import android.content.Context; import android.media.MediaPlayer;
package com.ustr.eMIRnew; import java.util.ArrayList; import java.util.HashMap; import android.R; import android.app.Activity; import android.os.Bundle; import android.widget.ListView;
package com.rest; import java.io.IOException; import android.app.Activity; import android.os.Bundle; import android.util.Log; import android.view.View; import android.widget.Button;
package com.org.myOxygen.activities; import java.util.Stack; import android.app.Activity; import android.app.ActivityGroup; import android.app.LocalActivityManager; import android.content.Intent; import android.os.Bundle;
package com.Project_recording; import java.io.File; import java.io.IOException; import android.app.Activity; import android.media.MediaPlayer; import android.media.MediaRecorder; import android.os.Bundle;
This is my .java file in src: package com.wao.texttime; import java.util.Calendar; import android.app.Activity; import
package com.commonsware.android.layouts; import android.app.Activity; import android.os.Bundle; import android.view.View; import android.widget.Button; import java.util.Date; public class
package com.example.helloandroid; import java.util.ArrayList; import java.util.Arrays; import android.app.TabActivity; import android.os.Bundle; import android.view.Window; import android.widget.ArrayAdapter;
debug.java package com.himanshu; import android.app.Activity; import android.os.Bundle; import android.util.Log; public class BookShelfDebugActivity extends Activity

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.