Limitations on opening pdf file in Android

前端 未结 2 1696
难免孤独
难免孤独 2021-02-11 15:09

I am trying to opening some pdf from my Android application. I am using an Intent for doing that:

Intent intent = new Intent();
intent.setDataAndType(Uri.parse(u         


        
2条回答
  •  -上瘾入骨i
    2021-02-11 15:43

    It could be the file failed to be interpret by the Android PDF viewer app. Have you tried to copy/download the exact same file to your Android phone and open from there?

    Also, I'd suggest to use IntentChooser for launching the PDF viewer, just to play safe on no PDF viewer installed / giving user option to choose app:

    Intent intent = new Intent();
    intent.setDataAndType(Uri.parse(url), "application/pdf");
    Intent chooserIntent = Intent.createChooser(intent, "Open Report");
    startActivity(chooserIntent);
    

提交回复
热议问题