Improving inter-activity communication with Jetpack ActivityResult
Posted by Yacine Rezgui , Developer Advocate Whether you're requesting a permission, selecting a file from the system file manager, or expecting data from a 3rd party app, passing data between activities is a core element in inter-process communication on Android. We’ve recently released the new ActivityResult APIs to help handle these activity results. Previously, to get results from started activities, apps needed to implement an onActivityResult() method in their activities and fragments, check which requestCode a result is referring to, verify that the requestCode is OK, and finally inspect its result data or extended data. This leads to complicated code, and it doesn’t provide a type-safe interface for expected arguments when sending or receiving data from an activity. What are the ActivityResult APIs? The ActivityResult APIs were added to the Jetpack activity and fragment libraries, making it easier to get results from activities by providing type-safe contracts. These ...