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

  • Home
  • SEARCH
  • 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 8248447
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T23:11:28+00:00 2026-06-07T23:11:28+00:00

I am working with multiple Fragments under Android and am confused on how to

  • 0

I am working with multiple Fragments under Android and am confused on how to send and receive data from embedded apps.

For a simple explanation, I have a ListFragment and a MapFragment using the method explained here. This means that the List lives in the ListFragment class, however the MapActivity is an Activity that is called under the LocalActivityManagerFragment.

Everything works on the individual Fragments: Lists of waypoints, waypoints and current location implemented on the MapFragment. I also understand how to use getFragmentManager() to get individual Fragments and use their events. However, I cannot use this method to access a function under MapActivity. How can I use a command such as goToLocation (created under MapActivity) if I click on an item on the ListView, if I can’t simply use getFragmentManager??

  • 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-07T23:11:30+00:00Added an answer on June 7, 2026 at 11:11 pm

    For communication between a Fragment and an activity:

    Activity > Fragment:

    Call on the public methods of the fragment using this.

    TestFragment testFrag = (TestFragment) getFragmentManager().getFragmentById(R.id.testfragment);
    
    if(testFrag != null && testFrag.isAdded())
        testFrag.testMethod("Test");
    

    Fragment > Activity

    To send messages to the activity you need to use an interface so in the fragments class add this: (Not in any method)

    public interface testInterface{
        public void testMethod(String test);
    }
    
    testInterface mCallback;
    
    @Override
    public void onAttact(Activity a){
        try{
            mCallback = (testInterface) a;
        }catch(Exception e){
            //TODO
        }
    }
    

    then in any method you can go and call this:

    mCallback.testMethod("hello");
    

    then for the activity make it so it implements testInterface and import the interface

    and then have this method in the activity

    @Override
    public void testMethod(String testString){
    
    }
    

    🙂 Just ask for anything more.


    Edit

    From my first read of your question I thought this is what you wanted sorry, could still cover what you wanted.

    I think what your asking for is just a onItemClick method right?

    so in the interface you could have

    public void onItemClicked(AdapterView<?> parent, View view, int position, long id);
    

    then when onItemClick has been called in the fragment you can use this in it

    mCallback.onItemClicked(parent, view, position, id);
    

    and then in the activity, given its implementing the interface you can have

    @Override
    public void onItemClicked(AdapterView<?> parent, View view, int position, long id){
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So I have been working with multiple different MS Access apps at work (about
I am working with multiple XElement objects to provide some user-specified data for several
If I have multiple SVN working copies checked out to my local PC, what's
I am working with multiple databases in a PHP/MySQL application. I have development, testing,
I'm working with multiple third party webservices (from the same vendor) that appear to
I have a problem in that I have switched my (working) multiple-database nhibernate solution
OK I have been working on multiple approaches to this but can't really find
I have try with toggle function in jquyer but its not working for multiple
I have an app that uses fragments, its working ok, but I have now
I'm working with Qt. I have multiple shaders working, however passing uniform arrays seems

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.