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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T01:40:22+00:00 2026-05-27T01:40:22+00:00

I am facing one problem in AsyncTask in my application in Android. The problem

  • 0

I am facing one problem in AsyncTask in my application in Android. The problem is, I am starting another Activity from AsyncTask in my application which runs fine when its layout has simple Button, but when I am using ImageButton its giving me error of handler and looper.loop. I am not getting the reason why this kind of error is occurring. I am displaying menus with images in calling Activity.

Can anybody suggest me what is the problem in this and how can I achieve this kind of functionality?

protected void onPostExecute(Void result) {
    super.onPostExecute(result);
    if (Dialog != null && Dialog.isShowing()) {
       Dialog.dismiss();
       locationManager.removeUpdates(locationListener);
       Intent homeIntent = new Intent(ATMActivity.this.getApplicationContext(), HomeMenuActivity.class);
       homeIntent.putExtra("lat", latitude);
       homeIntent.putExtra("lng", longitude);
       startActivity(homeIntent);
    }
}

XML File :-

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:gravity="center"
    android:orientation="vertical" >

    <ImageButton
        android:id="@+id/imageButton1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@drawable/atm_icon"
        android:onClick="buttonClicked" />

</LinearLayout>

Another Activity Class :-

protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
       setContentView(R.layout.home);

       Button btn = (Button) findViewById(R.id.imageButton1);
       btn.setHint("ATM");
       float latitude = getIntent().getFloatExtra("lat", 0);
       float longitude = getIntent().getFloatExtra("lng", 0);
       Toast.makeText(getApplicationContext(), "Location Floats:- " + latitude + "," + longitude, Toast.LENGTH_LONG).show();
}
  • 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-27T01:40:23+00:00Added an answer on May 27, 2026 at 1:40 am

    Without the full stack trace it’s hard to say for sure, but my best guess is you’re actually getting a ClassCastException.

    Your ATMActivity is trying to cast imageButton1, defined in xml as an ImageButton, to a Button. This is not possible, as the latter is not a superclass of the former.

    // Can't do below: Button is not a superclass of ImageButton
    Button btn = (Button) findViewById(R.id.imageButton1);
    

    Since you’re starting the activity from the onPostExecute of an AsyncTask, you’ll probably find some stuff mentioning a looper/handler in the stack trace.

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

Sidebar

Related Questions

I am facing one strange problem, when i run my android application on the
I am facing one problem. I have to create asp.net 4.0 web application which
We are facing one problem in managing test data (xmls which is used to
We are facing one problem with facebook. we integrated FB in our web application,
I am working on one application, i am facing one problem on Internet Explorer
I am facing this bizarre problem in my asp.net mvc application: In one page
I am facing a problem with one of my XBAP (WPF Browser application) projects:
I am new to winforms and facing one problem in my application. I am
I am facing one problem regarding unlocking the device when Service launched activity when
I am facing one problem from last one week. I have one list having

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.