Java callback methods are used to implement event handlers and other common Android programming elements. These sorts of callbacks can be used in Android apps whenever you want Java objects to communicate with each other. For example, you might have an activity whose layout contains a fragment. When something happens within the fragment, you might need to communicate that to the containing activity. In some programming environments this might be done with an event dispatching system. The fragment might dispatch an event, and the container would listen for and respond to the event. In Android though, you typically implement this with a code in the fragment class calls a method in the containing object - a callback.
- [Voiceover] Java callback methods are used to implement…event handlers and other common Android design patterns.…But you can also use callback methods to let Java objects…communicate with each other at runtime.…For example, you might have an activity…whose layout contains a fragment.…When something happens within the fragment,…you might want to communicate that…to the containing activity.…In some programming environments,…this might be done with an event dispatching system.…The fragment might dispatch an event and…the container would listen for and respond to that event.…
In Android though, you typically implement…this with callback methods.…The fragment class calls a method in the containing class.…Here are the steps.…I'm working in the project "Custom Callbacks."…I'll add a new fragment to the project.…I'll right-click on the project in the project window and…I'll choose New, Fragment, and…I'll select the first option, a blank fragment.…In this dialogue, I'll uncheck the option…to include fragment factory methods.…
Author
Updated
8/24/2017Released
3/18/2016Watch these Java tutorials to learn smarter, more efficient methods for Android app development.
- Preparing the development environment
- Packaging and running Android apps
- Optimizing Java code for Android
- Implementing event handler interfaces
- Defining custom callback methods
- Working with the Android SDK's Java packages
- Storing data
- Reading text files
- Parsing JSON and XML data
- Managing device sensors
- Playing audio
Skill Level Beginner
Duration
Views
Related Courses
-
Learning Java 8
with Peggy Fisher3h 9m Beginner -
Java Essential Training for Students
with Peggy Fisher3h 6m Intermediate -
Java 8 Essential Training
with David Gassner6h 7m Beginner
-
Introduction
-
Welcome48s
-
What you need to know2m 18s
-
Using the exercise files3m 38s
-
What's new in this update?1m 19s
-
-
1. Getting Started
-
2. Android's Implementation of Java
-
3. Common Java Design Patterns in Android
-
Manage async tasks in fragments11m 19s
-
4. The Android SDK's Java Packages
-
Manage local databases10m 57s
-
Read text files from assets9m 20s
-
Parse JSON formatted data8m 29s
-
Parse XML formatted data9m 52s
-
5. Android-Specific Java Packages
-
Manage device sensors8m 4s
-
Use text to speech6m 39s
-
Play audio files8m 39s
-
6. Java 8 Syntax for Android
-
Explore more Java syntax1m 24s
-
Conclusion
-
Next steps1m 13s
-
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.
CancelTake notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.
Share this video
Embed this video
Video: Define custom callback methods