Share Media to Other apps using Custom bottomsheet & Coroutines— Android

Tanmay Patil
2 min readJan 18, 2023

--

In android, we usually share media with other apps using intent which shows the android default system bottomsheet with a list of apps compatible with the given mime type. But if you see apps like Flipkart, mxplayer, Twitter, etc... uses a custom bottomsheet with a list of apps. Today we will discuss how to achieve it.

Image from pexels

To achieve this we will use queryIntentActivities to get a list of apps supporting a given type without blocking UI with the help of coroutines.

Just paste the above code and you are good to go. Now you will get a list of resolveInfo which you can pass to the recyclerView adapter of your bottomsheet.
Your adapter will look something like this :

Here is the final result : (Here I am using text/plain type)

Now on onClick you will receive the package name to which you want to send the data. With the help of intent pass the data to the given selected app.

Conclusion :
So we learned how to show a custom bottomsheet for sharing your data with the help of coroutines.
If you’ve any suggestions or doubts let me know through comments or Twitter :)

--

--