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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T17:48:55+00:00 2026-06-01T17:48:55+00:00

I have multiple activities in which I want to use same code in those

  • 0

I have multiple activities in which I want to use same code in those activity.
I finished it with having same bunch of code in each activity.
How can minimize this redundant code.
For doing this I dont want to create object and use it’s methods for removing redundancy…

Plz help…
Thank U….

  • 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-01T17:48:56+00:00Added an answer on June 1, 2026 at 5:48 pm

    the solution is simple: extends the class Activity, and add him all the methods you want.
    (I usually call this class BaseActivity for instance)
    then, when you are developing new activity – instead of extend the class Activity – extends the class BaseActivity you’ve made, which contain the methods you added..

    public class BaseActivity extends Activity
    {
    protected int mSomeValue;
    
    protected void someMethod1()
    {
    
    }
    
    protected void someMethod2()
    {
    
    }
    
    protected void someMethod3()
    {
    
    }
    
    }
    
    class SomeActivity extends BaseActivity
    {
    @Override
    protected void onCreate(Bundle savedInstanceState)
    {
        // TODO Auto-generated method stub
        super.onCreate(savedInstanceState);
        someMethod1();
    }
    }
    
    class SomeActivity2 extends BaseActivity
    {
    @Override
    protected void onCreate(Bundle savedInstanceState)
    {
        // TODO Auto-generated method stub
        super.onCreate(savedInstanceState);
        someMethod1();
    }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a scenario and want to use multiple ReceiveAndSendReply activities running in parallel
I have a login session ID which multiple activities need to use. How do
We have multiple MFC apps, which use CMutex( false, blah ), where blah allows
I'm starting an Android app which will have multiple Activities. It will be using
In my application, I have 2 list activities which can start one or the
I have multiple actions running at the same time. When Action 1 is finished
I am confused, I have multiple parts of my Activity which I have to
I have an application which has multiple activities associated with it. When the user
I'm confused something fierce over having multiple views. I simply want to have a
I currently have an app that requires connection to a server in multiple activities.

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.