Deep Dive into Activity Results API — No More onActivityResult()

ActivityResultContracts by Examples

Wajahat Karim
AndroidPub
Published in
7 min readMay 1, 2020

--

Since Android came into existence in 2007, Activity has been one of its core components. One of the most common tasks in apps is transferring data between two Activities. Until now, Intents and onActivityResult were the only choice.

Through the combination of these two parts, developers are able to transfer data from one Activity to another and get data back easily.

Let’s elaborate through an example: your app wants to capture an image and display it to the user. You either write your own custom Camera or delegate the task of fetching an image to Android through Intents. In this second scenario, Android system will open the user-preferred Camera app, capture the image and deliver the requested data to your activity by calling onActivityResult() method.

I am working on the video tutorial of this article and it will be uploaded on my YouTube channel soon. Please subscribe to get watch latest Android tips and tutorials.

--

--

Wajahat Karim
AndroidPub

🔥 Google Dev Expert (GDE) in Android . 📱 Android Dev . 💻FOSS Contributor . 📝 Tech Writer . 🎤 Public Speaker — 🌐Subscribe at https://wajahatkarim.com