Limitations on opening pdf file in Android

前端 未结 6 1496
暗喜
暗喜 2021-02-11 15:04

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         


        
6条回答
  •  长发绾君心
    2021-02-11 15:56

    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);
    

提交回复
热议问题