Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/199.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在android中使用Intent拾取PDF文件_Android_Android Intent - Fatal编程技术网

在android中使用Intent拾取PDF文件

在android中使用Intent拾取PDF文件,android,android-intent,Android,Android Intent,嘿,我是android新手,我需要使用Intent选择pdf文件。我正在使用此代码设置MIME的类型 Intent intent = new Intent(Intent.ACTION_GET_CONTENT); intent.setType("pdf/*") 但是它没有按照我想要的方式工作,请提供任何建议,或者我可以对现有代码进行一些更改 这样做intent.setType(“application/pdf”)请尝试以下代码: Intent intent = new Intent(Intent

嘿,我是android新手,我需要使用
Intent
选择
pdf
文件。我正在使用此代码设置MIME的类型

Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
intent.setType("pdf/*")

但是它没有按照我想要的方式工作,请提供任何建议,或者我可以对现有代码进行一些更改

这样做
intent.setType(“application/pdf”)

请尝试以下代码:

Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setType("application/pdf");
intent.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
startActivity(intent);

如何通过intent仅打开word文件??只需设置word文件的mime类型,例如.docx文件mime类型将为:application/vnd.openxmlformats-officedocument.wordprocessingml.document so intent.setType(“application/vnd.openxmlformats-officedocument.wordprocessingml.document”);这里给出了Microsoft Office MIME类型。我的系统的文件选择器将Google Drive显示为提供程序。如果单击“驱动器”,我可以选择一个非PDF文件。除了通过仅使用额外的本地驱动器来完全消除驱动器之外,如何解决这个问题?