startActivity报错exposed beyond app through Intent.getData()
App 报错 Intent Through Beyond
2023-09-27 14:21:58 时间
背景:
需要调用外部已安装的APP来打开文件,直接报错。
解决:
1、的application节的里面
<provider android:name="androidx.core.content.FileProvider" android:authorities="com.xx.xxx.fileprovider" android:exported="false" android:grantUriPermissions="true"> <meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@xml/file_paths" /> </provider>
2、file_apths;
<?xml version="1.0" encoding="utf-8"?> <paths xmlns:android="http://schemas.android.com/apk/res/android"> <external-path path="." name="external_storage_root" /> </paths>
3、打开比如docx
//android获取一个用于打开Word文件的intent public static Intent getWordFileIntent(Context mContext, String Path) { File file = new File(Path); Intent intent = new Intent("android.intent.action.VIEW"); intent.addCategory("android.intent.category.DEFAULT"); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); Uri uri = FileProvider.getUriForFile(mContext, "com.xx.xxx.fileprovider", file);//Uri.fromFile(file); intent.setDataAndType(uri, "application/msword"); return intent; }
记得用startActivity开启哦。
不出什么意外的话,会弹出一个列表,选择打开文件。
相关文章
- Android常见App加固厂商脱壳方法的整理
- APP项目怎么测?
- Google Earth Engine APP(GEE)—查看亚马逊平原的1984——至今的每一景影像
- minikube addons enable ingress 报错waiting for app.kubernetes.io/name=ingress-nginx pods: timed out
- uni-app - 使用echarts 图表(H5、APP)
- uni-app - 每次点击底部 tabBar 导航栏都触发函数(利用生命周期函数)
- 删除setup app 激活A7 IOS
- 微信小程序 app.js globalData 赋值报错
- Android hybrid App项目构建和部分基本开发问题
- 基于Java实现Android 蛤蛤连连看有APP【100010567】
- macOS Swift精品项目之查找图像的主色App 使用CIE LAB颜色空间和k-means聚类算法(教程含源码)
- adb怎么判断是否有root权限,并更改system/app内容
- Flutter App (一) —— ListView以及GridView的列表展示与Item点击事件
- 单个APP页面支持屏幕旋转
- uni-app 发主H5是出现npx browserslist --update-db 的问题
- uniapp微信APP支付踩坑指南:报错errMsg: "requestPayment:fail errors"
- 【HMS Core】升级SDK报错app_id failed: java.io.FileNotFoundException: agconnect-services.json
- APP之红点提醒三个阶段
- MATLAB 手把手带你制作第一个APP designer程序(电子词典)
- Android学习之修改app名字和修改project名字的方法
- Android測试APP工具(一)
- Android Error:Execution failed for task ':app:preDebugAndroidTestBuild'. > Conflict with dependency
- 报错 - Command /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/lex failed with exit code 1
- 一个优秀开源单点登录项目分布式单点登录框架。只需要登录一次就可以访问所有相互信任的应用系统。拥有“轻量级、分布式、跨域、Cookie+Token均支持、Web+APP均支持“等特性