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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T17:23:47+00:00 2026-06-18T17:23:47+00:00

The Android developers site has a great article on how to use interfaces to

  • 0

The Android developers site has a great article on how to use interfaces to communicate between:

  1. A Fragment and its hosting Activity
  2. Two Fragments hosted by the same Activity

I am struggling to apply this concept to nested fragments. In particular, getActivity() or Fragment#onAttach(Activity) tell you what Activity is hosting a Fragment.

What is the equivalent in case of nested fragments? How does a “child” Fragment know what “parent” Fragment it is included in? And without knowing this, how can a child Fragment pass events up to its parent Fragment?

An obvious way is to broadcast intents from the child Fragment and have the parent Fragment listen for the broadcast, but I’d rather use the interface-based approach.

  • 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-18T17:23:49+00:00Added an answer on June 18, 2026 at 5:23 pm

    It turns out there is a getParentFragment() method introduced to cater to nested fragments. It is available on android.app.Fragment from API 17, but can be used on older versions using android.support.v4.app.Fragment.

    I can’t believe I overlooked this API!

    EDIT:

    I came across this gist that makes this process of figuring out the parent component (whether Fragment or Activity) easy, elegant and safe!

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

Sidebar

Related Questions

The Design Page of Android Developers Site has a category about colors. Color |
On Android Developer Site has said that : We shouldn't use long operations work
According to Android Developers site, the Bitmap.recycle() method definition is: Free the native object
I followed this tutorial from the Android Developers site. But, the auto complete doesnt
I'm trying to follow instructions from Android developers site but I must be doing
I have been reading the following text on the Android Developers Site, specifically under
I have launched an emulator with a: android avd (although the android developers site
Just download latest Android SDK version from Android developers site, run ./android tool (i
I'm working on the Tabs example from Google Android Developers site (http://developer.android.com/resources/tutorials/views/hello-tabwidget.html) but I'm
i am trying to run sample projects from Samples from developers site of android.but

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.