Query Apps that can handle a external DeepLink in Android using Package Manager

Mudit Sen
3 min readNov 27, 2018

So what is a DeepLink?

DeepLinks are a concept that helps users navigate between the web and applications. They are basically URLs which navigate users directly to the specific content in applications.

So DeepLink is an URL which can directly land you to a particular application in your Android or IOS device.

But what if there is more than one application that can handle a particular type of link. Usually, this is the case when there more one application that can edit your image, crop your image, play a video and social media applications that accept any type of content on your phone. Simple example of this would be when you are in your gallery application and click share. Then all the apps that can handle an Image Intent pops.

In my case it was UPI applications that handles payments. And when this is the case then android displays an in-built application picker bottom sheet from where you can select an application carry on with your task.

The UPI DeepLink looks like this

upi://pay

But what if you want a custom-designed application picker? What if you want remove some applications from the default Android App Picker?

Well you can’t but you can create your own custom app picker dialog and edit the result any way you want.

But then you will need a way to find all those applications on your android phone.
Android system provides a Package manager class to fetch all the applications in one device and allows you to filter them using DeepLinks.

Now, let's go through the code

Above is a method
getAppsInstalled(String deeplink)
that accepts deeplink as a parameter.

For now to test you can try
geo://32.9096235,-117.1840923
while you have Google maps and Uber both on your phone. You will find "getAppsInstalled"a method returning a List of these two applications.

Now you can use the returned list and OptionModel to display the app icon and app name in your custom recycler view or list view.

Now his is a simple tutorial that can be used in many ways. You can create your custom Application Picker, also prioritise which application comes first in your list. You can also eliminate any application you don’t want. You can create an overall better User experience with this. Feel free to comment if you have any doubts.

This story is published in Noteworthy, where 10,000+ readers come every day to learn about the people & ideas shaping the products we love.

Follow our publication to see more product & design stories featured by the Journal team.

--

--