I'm trying to open a pdf file from a uri by using an implicit intent like so:
try{
Intent intent = new Intent();
intent.setAction(Intent.ACTION_VIEW);
intent.setDataAndType(pdfUri, "application/pdf");
startActivity(intent);
}catch(ActivityNotFoundException e){
e.printStackTrace();
Log.e(LOG_TAG,e.getMessage());
}
And this works perfectly fine on my OnePlus X(API-Level 23), but the I tried it on a Samsung GT S7582 (API-Level 17), where it's not working for some reason.
I then tried to use an IntentChooser, but this also did not worked:
Intent chooser = Intent.createChooser(intent, "Open with");
startActivity(chooser)
After that I tried to share a string and that worked perfectly fine on both devices:
Intent intent = new Intent();
intent.setAction(Intent.ACTION_SEND);
intent.putExtra(Intent.EXTRA_TEXT, "Test 123 abc");
intent.setType("text/plain");
startActivity(intent);
An app which is capable of opening PDF files is definitly installed on both devices and the ActivityNotFoundException is not thrown.
Has anyone any idea why the intent isn't working on some devices?