# The case for Fragment Callbacks

DevFeed: [The case for Fragment Callbacks](<https://devfeed.tech/articles/the-case-for-fragment-callbacks-30549.md>)

Original publisher: [Read original article](<https://ryanharter.com/blog/2013/02/the-case-for-fragment-callbacks/>)

Published: 2013-02-18T07:00:00Z

Content type: article

Language: en

Sources: [Blogs on Ryan Harter](<https://devfeed.tech/sources/blogs-on-ryan-harter.md>)

Topics: [Android](<https://devfeed.tech/topics/android.md>), [interfaces](<https://devfeed.tech/topics/interfaces.md>), [Code](<https://devfeed.tech/topics/code.md>), [Development](<https://devfeed.tech/topics/development.md>)

Tags: [android](<https://devfeed.tech/tags/android.md>), [api](<https://devfeed.tech/tags/api.md>), [fragment](<https://devfeed.tech/tags/fragment.md>), [google](<https://devfeed.tech/tags/google.md>), [google-i-o](<https://devfeed.tech/tags/google-i-o.md>), [interface](<https://devfeed.tech/tags/interface.md>), [interfaces](<https://devfeed.tech/tags/interfaces.md>)

## AI overview

This article recommends using callback interfaces for communication between Android Fragments and their parent activities. It argues that casting the parent activity creates tightly coupled code, while callbacks improve reuse, maintainability, flexibility, and separation of responsibilities.

## Source excerpt

Fragment are a great addition to Android. They allow reusability of sections of your views at the controller layer, and they also provide better encapsulation of your app's logic. This can really help developers speed up code development and also keep their code clean, which makes it easier to maintain. All of these benefits are available if you follow a few guidelines when developing your code. One of the biggest mistakes that I see developers make, particularly those coming from other platforms, is casting the parent activity. The Fragment API provides methods for communicating with the parent activity because there are many things, like navigation, that should not be handled by the Fragment. This requires a mechanism for the Fragment to notify the parent Activity when certain activities occur.