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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T12:33:44+00:00 2026-05-19T12:33:44+00:00

Is there any way in android to intercept activity method calls (just the standart

  • 0

Is there any way in android to intercept activity method calls (just the standart ones, like “onStart. onCreate”)?
I have a lot of functionality that must be present in every activity in my app, and (since it uses different types of activities (List, Preferences)) the only way to do it is to create my custom extensions for every activity class, which sucks 🙁

P.S. I use roboguice, but since Dalvik doesn’t support code generation at runtime, I guess it doesn’t help much.

P.S.S. I thought about using AspectJ, but it’s too much of a hassle since it requires a lot of complications (ant’s build.xml and all that junk)

  • 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-19T12:33:45+00:00Added an answer on May 19, 2026 at 12:33 pm

    You could delegate all the repetitive work to another class that would be embedded in your other activities. This way you limit the repetitive work to creating this object and calling its onCreate, onDestroy methods.

    class MyActivityDelegate {
        MyActivityDelegate(Activity a) {}
    
        public void onCreate(Bundle savedInstanceState) {}
        public void onDestroy() {}
    }
    
    class MyActivity extends ListActivity {
        MyActivityDelegate commonStuff;
    
        public MyActivity() {
            commonStuff = MyActivityDelegate(this);
        }
    
        public onCreate(Bundle savedInstanceState) {
            commonStuff.onCreate(savedInstanceState);
            // ...
        }
    }
    

    This minimalises the hassle and factorises all common methods and members of your activities. The other way to do it is to subclasse all the API’s XXXActivty classes 🙁

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

Sidebar

Related Questions

Is there any way to have something that looks just like a file on
Is there any sample? I have my android application and I need to connect
Is there any way to make Android emit a sound of arbitrary frequency (meaning,
Is there any possible way to install Android Emulator itself on the windows. I
Is there any way to monitor the performance of a thread on Android phone.
Is there any way of accessing the internal SD card on Android devices that
develop android apps that should support iphone,ipad,android.is there any way for developing this kind
Is there any way for an Android application to declare requested permissions as optional?
Is there any way to handle OutOfMemoryException in Android while using Bitmap of large
Is there any way to listen to incoming calls by extending BroadcastReceiver to listen

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.