Android 13下React Native无法打开DocumentDirectoryPath中的Zip文件
Android 13 - 系统特定问题
我已将Zip文件下载至DocumentDirectoryPath,但尝试多种方案均无法打开该文件,以下是试过的方法及遇到的问题:
方案1:使用React Native Linking工具
Linking是RN中用于打开文件管理器的工具,执行代码:
await Linking.openURL(`file://${zipFilePath}`, mimeType);
报错信息:Unable to open file manager for BineryDocument.zip,已确认文件确实存在。
方案2:使用react-native-intent-launcher包
该包下载量较低,执行代码:
await IntentLauncherAndroid.startActivity({ action: IntentLauncherAndroid.ACTION_VIEW, data: 'file:///path/to/your/file', type: 'application/your-mime-type', });
问题:无法打开目标Zip文件。
方案3:使用react-native-file-viewer包
执行代码:
try { await FileViewer.open(filePath, { showOpenWithDialog: true }); } catch (error) { console.error('Error opening file:', error); }
问题:同样无法打开文件。
文件路径
/data/user/0/co.binery.app/files/BineryDocument.zip
内容的提问来源于stack exchange,提问作者Aamirkhan
相关产品推荐
相关产品推荐

