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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T19:21:22+00:00 2026-06-10T19:21:22+00:00

One question for design about communicating between fragments, why would someone use a bit

  • 0

One question for design about communicating between fragments,

why would someone use a bit complicated callback pattern implementing listeners,
versus using a simple static methods from a class we want to call a method from (something
similar to using Singleton for some methods/attributes).
Is there any performance issue or it is “just” a bad OO programming practice for Android/Java?
So the easy way for two-way communication could be:

MyActivity activity
    Fragment A
    Fragment B
static method canBeCalledFromAnywhere() {}
method activityMethod()
    call FragmentA.doSomething();
    call FragmentB.doSomething();



FragmentA
    onCreate()
        onMe = this;

static method doSomething()
    do something with static or use onMe for instance;

method oneMethodFragmentA()
    call MyActivity.canBeCalledFromAnywhere();



FragmentB
onCreate()
    onMe = this;

static method doSomething()
    do something with static or use onMe for instance;

method oneMethodFragmentB()
    call MyActivity.canBeCalledFromAnywhere();
  • 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-10T19:21:23+00:00Added an answer on June 10, 2026 at 7:21 pm

    It’s better to use clearly specified communication interface than make assumption there is one. Therefore if you define interface for your communication then:

    1. your Fragment can easily check if parent Activity implements this
      interface, so Fragment will be able to communicate its needs,
    2. to define interface you need to think it over a bit instead of just
      start coding, which leads to some sort of standardization and this is good,
    3. it’s easy to maintain updates of interface as compiler will complain
      if you change interface, but no implementation.

    You may also want to read this Android SDK article.

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

Sidebar

Related Questions

I'm new in Design Patterns so I have one question about the Builder Pattern.
I have a design question about the communication between the model and the presenter
one question about PHP Development. I am building up some Form Fields for Calculations.
One question about protected constructor. I learnt that the protected constructor can be used
i have one question about jquery ajax().. I created a table grid and there
I have one question about searching and counting files in directories and subdirectories. I
I have one question about Yii framework, and I need your help. Basicly, I
I have a question about usability/design. I currently am using some JQuery to hide/show
I have a naive question about OOP design patterns. This is over-architecture, but I
I've a simple Design question and am not really sure about pro´s and con´s.

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.