我正试图在我的应用程序内打开Gallery内置应用程序中的图像/图片.
我有一张图片的URI(图片位于SD卡上).
你有什么建议吗?
我已经提取了图像uri,现在我想用Android的默认图像查看器打开图像.甚至更好,用户可以选择用于打开图像的程序.如果您尝试打开文件,File Explorers之类的东西会提供给您.
我想显示一个活动选择器,显示可以查看和/或编辑某些数据的所有应用程序.有没有一种简单的方法可以做到这一点,还是我必须实现自己的活动选择器对话框?或许我可以只是亚类Intent?谢谢.
我试图从外部存储器获取文件,然后我必须使用意图将该文件发送到pdf阅读器.以前下面的代码工作正常,但安装Android 6(Marshmallow更新)后,我的代码无法正常工作并获取Toast消息
" 无法访问此文件检查位置或网络,然后重试."
(这是由于新的Android运行时权限).我刚尝试了所有的解决方案(内容提供商等,但没有工作)任何解决方案?
File file = new File(getFilesDir(), "myfile.pdf");
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.fromFile(file), "application/pdf");
intent.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
Intent intentChooser = Intent.createChooser(intent, "Choose Pdf Application");
try {
startActivity(intentChooser);
} catch (ActivityNotFoundException e) {
//com.adobe.reader
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://play.google.com/store/apps/details?id=com.adobe.reader")));
}
Run Code Online (Sandbox Code Playgroud)