首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >如何在颤振中使用android_intent_plus打开pdf?

如何在颤振中使用android_intent_plus打开pdf?
EN

Stack Overflow用户
提问于 2022-06-28 17:13:22
回答 1查看 352关注 0票数 0

我有一个.pdf下载安卓文件夹,我想打开它与颤振。

我试过:

代码语言:javascript
运行
复制
final AndroidIntent intent = AndroidIntent(
                  action: 'android.os.Intent.ACTION_VIEW', //android.os.Intent.ACTION_VIEW  action_view
                  data: Uri.encodeFull("/storage/emulated/0/Download/myfile.pdf"), // content:// file://
                  //type: "application/*",
              flags: [
                Flag.FLAG_GRANT_READ_URI_PERMISSION,
                Flag.FLAG_GRANT_PERSISTABLE_URI_PERMISSION,
                Flag.FLAG_ACTIVITY_NEW_TASK
              ]);
              intent.launch();

但我得到了以下错误:

代码语言:javascript
运行
复制
V/IntentSender( 8997): Sending intent Intent { act=android.os.Intent.ACTION_VIEW dat=/storage/emulated/0/Download/myfile.pdf flg=0x10000041 (has extras) }
E/MethodChannel#dev.fluttercommunity.plus/android_intent( 8997): Failed to handle method call
E/MethodChannel#dev.fluttercommunity.plus/android_intent( 8997): android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.os.Intent.ACTION_VIEW dat=/storage/emulated/0/Download/myfile.pdf flg=0x10000041 (has extras) }
dev.fluttercommunity.plus.androidintent.MethodCallHandlerImpl.onMethodCall(MethodCallHandlerImpl.java:95)
E/flutter ( 8997): [ERROR:flutter/lib/ui/ui_dart_state.cc(198)] Unhandled Exception: PlatformException(error, No Activity found to handle Intent { act=android.os.Intent.ACTION_VIEW dat=/storage/emulated/0/Download/myfile.pdf flg=0x10000041 (has extras) }, null, android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.os.Intent.ACTION_VIEW dat=/storage/emulated/0/Download/myfile.pdf flg=0x10000041 (has extras) }
E/flutter ( 8997): #0      StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:607:7)
E/flutter ( 8997): #1      MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:167:18)
E/flutter ( 8997): <asynchronous suspension>
E/flutter ( 8997): #2      AndroidIntent.launch (package:android_intent_plus/android_intent.dart:150:5)
E/flutter ( 8997): <asynchronous suspension>

我需要额外的许可吗?提供者?还要别的吗?有什么建议吗?谢谢<3

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2022-06-28 17:20:12

代码语言:javascript
运行
复制
try this
import 'package:open_file/open_file.dart';

OpenFile.open("/sdcard/example.pdf");
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/72790667

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档