Skip navigation

Java interfaces and callback methods

Java interfaces and callback methods: Building Flexible Android Apps with the Fragments API
Java interfaces and callback methods: Building Flexible Android Apps with the Fragments API

I’ve previously described how you can pass data to a fragment using arguments. You can set the arguments either directly from the activity that contains the fragment, or you can pass values to a factory method that handles the task. You also need to be able to communicate in the other direction, sending messages from the fragment to the containing activity. In some application frameworks, this is handled with events - that is, a nested component will throw an event that contains data, and the container will listen for and handle the event. In Android, you manage this sort of communication with callback methods. Here are the basic steps for defining and using callback methods from fragment to activity.

Resume Transcript Auto-Scroll
Skill Level Intermediate
2h 26m
Duration
90,370
Views
Show More Show Less
Skills covered in this course
Developer Mobile Apps Android

Continue Assessment

You started this assessment previously and didn't complete it. You can pick up where you left off, or start over.

Start My Free Month

Start your free month on LinkedIn Learning, which now features 100% of Lynda.com courses. Develop in-demand skills with access to thousands of expert-led courses on business, tech and creative topics.

Start My Free Month