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 set background like android:tileMode =repeat in windows phone7? if
Is there any way in Android that (to my knowledge) doesn't have java.text.Normalizer, to
Is there any way for an Android phone with NFC (Nexus, Galaxy, etc.) to
Is there any way to convert a android.graphics.Bitmap instance into jpeg in android?
Is there any way to programmatically tell android to open the keyboard when the
Is there any way to disable localization in an Android application? It must use
Is there any way to configure the titanium android such that it won't show
Is there any way to detect whether an android phone is in sleep mode
Is there any way to play video in Android App widget.
Is there any way to get the previously associated Wifi networks for an Android

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.