Running a specific application on Android

I know how to download a PDF file in Android. But if more than one PDF viewer is installed, Android displays a list of choices. I want to download a PDF file using a special PDF viewer (say DroidReader). How to do it?

+3
source share
2 answers

Then specify the full name of the operation:

    Intent intent = new Intent();
    ComponentName comp = new ComponentName("com.package.name.of.droidreader", "com.package.name.of.droidreader.DroidReader");
    intent.setComponent(comp);
    startActivity(intent);

To find out what the name and activity of the package is, you can look at the output adb logcat: when you open the activity that it registers there. And, of course, set the intent correctly so that the DroidReader knows which file to open.

, , startActivity try-catch, ActivityNotFoundException ( , ).

+1

, , , .

, , Intent.setPackage(), , . :

Intent intent = new Intent(Intent.ACTION_VIEW, uriToView);
intent.setPackage("com.package.name.of.droidreader");
startActivity(intent)
+2

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


All Articles