在PHP中强制下载后自动打开PDF

在PHP中强制下载后自动打开PDF,php,android,pdf,download,Php,Android,Pdf,Download,我有以下来自HTML应用程序的PHP代码(用户在Android上使用Chrome浏览器) 当用户单击一个图标时,它将强制将文件(在公共根目录之外)下载到android下载文件夹中(使用上述代码)。但我们希望PDF在下载打开后自动打开(就像单击a href链接一样)。这可能吗?打开一个意向: File file = new File(Environment.getExternalStorageDirectory().getAbsolutePath()+"/example.pdf"); Intent

我有以下来自HTML应用程序的PHP代码(用户在Android上使用Chrome浏览器)

当用户单击一个图标时,它将强制将文件(在公共根目录之外)下载到android下载文件夹中(使用上述代码)。但我们希望PDF在下载打开后自动打开(就像单击a href链接一样)。这可能吗?

打开一个意向:

File file = new File(Environment.getExternalStorageDirectory().getAbsolutePath()+"/example.pdf");
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.fromFile(file), "application/pdf");
intent.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
startActivity(intent);

是来源

谢谢您的评论。但我不是在开发一个本地应用程序,而是一个HTML应用程序。
File file = new File(Environment.getExternalStorageDirectory().getAbsolutePath()+"/example.pdf");
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.fromFile(file), "application/pdf");
intent.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
startActivity(intent);