How to check if a file can be opened by a third-party application before downloading

In my application, I want to download a file and view it. The problem is that I need to check whether any third-party application is installed on the device that can open the file format (Mime) before downloading it. Is it possible?

+4
source share
1 answer

Create an ACTION_VIEW Intent with the correct MIME type and fake file path (or, even better, the path you are about to load). Then use PackageManager and queryIntentActivities() - if you return a list with 1 + elements in it, then startActivity() on this Intent will succeed after loading the file.

+5
source

Source: https://habr.com/ru/post/1402228/


All Articles