Android报错: exposed beyond app through Intent.getData()
Posted 王睿丶
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Android报错: exposed beyond app through Intent.getData()相关的知识,希望对你有一定的参考价值。
androidManifest.xml
在<application 里添加
android:networkSecurityConfig="@xml/fileproviderpath"
<provider
android:name="androidx.core.content.FileProvider"
android:authorities="com.example.silentinstallation.fileprovider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/fileproviderpath"
/>
</provider>
res/xml/fileproviderpath
<?xml version="1.0" encoding="utf-8"?>
<paths xmlns:android="http://schemas.android.com/apk/res/android">
<root-path name="root" path="."></root-path>
<files-path
name="file"
path="."></files-path>
<files-path
name="files"
path="."></files-path>
<cache-path
name="cache"
path="."></cache-path>
<external-path
name="external"
path="."></external-path>
<external-cache-path
name="external_cache"
path="."></external-cache-path>
<external-files-path
name="external_file"
path="."></external-files-path>
<external-path name="external_files" path="."/>
</paths>
安装APK代码
String path = "/sdcard/youku.apk";
@Override
protected void onCreate(Bundle savedInstanceState)
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.putExtra("ISSILENT",1);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
Uri uri;
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
intent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
uri = FileProvider.getUriForFile(this,"com.example.silentinstallation.fileprovider",new File(path));
intent.setDataAndType(uri,"application/vnd.android.package-archive");
else
uri = Uri.parse("file://" + path);
intent.setDataAndType(uri, "application/vnd.android.package-archive");
startActivity(intent);
以上是关于Android报错: exposed beyond app through Intent.getData()的主要内容,如果未能解决你的问题,请参考以下文章
安卓7.0遇到 android.os.FileUriExposedException: file:///storage/emulated.. exposed beyond app through In
android 7.0拍照问题file:///storage/emulated/0/photo.jpeg exposed beyond app through ClipData.Item.getUri
Android N安装apk报错:android.os.FileUriExposedException
CDH6.3.2 Hive on spark报错is running beyond physical memory limits
spark运行任务报错:Container [...] is running beyond physical memory limits. Current usage: 3.0 GB of 3 GB
安卓系统广播暴露设备信息-Android System Broadcasts Expose Device Information