如何在Android Studio 3.1.1中带来默认的PDF Opener选项

时间:2018-07-23 06:53:10

标签: java android pdf itext

我已经制作了一个将图像转换为pdf的应用程序,它可以通过设备中存在的pdf打开器打开pdf。我面临的问题是,如果设备中存在多个pdf打开器,则不会显示“记住我”选项。

我是否可以通过编程方式启用相同的方法?

1 个答案:

答案 0 :(得分:0)

//更改设备的默认pdf阅读器,例如this->

Try clearing the defaults for the Google PDF Viewer app. You can do this on Android 4.x - 5.x by doing the following:

Go to Settings -> Apps -> All.
Scroll down to Google PDF Viewer app and tap on it.
Scroll down to the Launch by default section and tap the "Clear Defaults" button.
Next time you try to open a PDF, a pop-up should present you with options of all the installed apps that handle PDF viewing.

//用于打开android文件

Intent intent = new Intent(Intent.ACTION_VIEW);
File file = new File( filename  );
intent.setDataAndType( Uri.fromFile( file ), "application/pdf" );
startActivity(intent);