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

  • Home
  • SEARCH
  • 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 8473029
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T17:14:12+00:00 2026-06-10T17:14:12+00:00

I have an Android application that uses a class that extends the Activity class,

  • 0

I have an Android application that uses a class that extends the Activity class, let’s call it MyActivity. In that class I have a handler that handles various things. Now the activity that extends MyActivity class should be able to expand these things, that is it must be able to handle other things than MyActivity.

Here’s an example of what I want:

This is my modified Activity class that has a handler:

class MyActivity extends Activity {
    protected Hander myActivityHandler = new Handler()
    {
        @Override
        public void handleMessage(Message msg) {
            switch(msg.what)
            {
            case CASE_1:
                // do stuff
                break;
            case CASE_2:
                // do other stuff
                break;
            }
        }
    }
}

And here’s the class that extends that class and I want to add more cases to the handler:

class MySuperSpecialActivity extends MyActivity {
    // add/override cases of inherited myActivityHandler handler
}

I don’t know if it’s even possible, there’s probably a better way to achieve this functionality, but that’s how I started my code and a MyActivity class was necessary as it’s used a lot.

  • 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-06-10T17:14:13+00:00Added an answer on June 10, 2026 at 5:14 pm

    You may consider to implement Handler.Callback in your Activity:

    public class MainActivity extends Activity implements Handler.Callback {
    
        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            Handler handler = new Handler(this);
        }
    
        @Override
        public boolean handleMessage(Message msg) {
            // Handle your message here
            return false;
        }    
    }
    

    Inherit new Activity from this Activity and overwrite “handleMessage”:

    public class AnotherActivity extends MainActivity {
        @Override
        public boolean handleMessage(Message msg) {
            super.handleMessage(msg);
            return super.handleMessage(msg);
        }
    
    }   
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a simple Android application that uses an instance of a class, let's
I have an Android application that uses the Android database to create tables and
I have a simple Android application that uses a JAR I have built. When
I have a Web Service and an Android application that uses this web service.
I am building an android application that uses several third party libraries. I have
I have a problem with my android application. That application which uses the kSOAP
I have an android application that launches a child Activity under certain situations. Both
I have written a simple Android application that uses a sqlite database which is
I have an Android application that uses the well known Strategies for Legacy Applications
I have an Android application that connects to Facebook to request authorization of an

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.