I know how to load a PDF file in Android. But if more than one PDF viewers are installed, Android shows a list to choose from. I want to load my PDF file with a specific PDF viewer (say DroidReader). How to do this?
Then specify the complete name of the activity:
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 know what the package name and activity are, you could take a look at the adb logcat
output: when you open an activity it gets logged there. And, of course, configure the intent correctly so that the DroidReader know what file to open.
Lastly, but important, you should surround the startActivity
method with a try-catch
block catching the ActivityNotFoundException
(I'm sure that most of the handsets won't have that specific app).