Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/194.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/django/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 如何使文件提供程序可用于其他应用程序?_Android_Provider_Android Contentresolver_Android Fileprovider - Fatal编程技术网

Android 如何使文件提供程序可用于其他应用程序?

Android 如何使文件提供程序可用于其他应用程序?,android,provider,android-contentresolver,android-fileprovider,Android,Provider,Android Contentresolver,Android Fileprovider,其他应用程序是否可以使用文件提供程序 manifest.xml ... <provider android:name="android.support.v4.content.FileProvider" android:authorities="com.example.myapp.fileprovider" android:exported="true" android:grantUriPermissions="false"

其他应用程序是否可以使用文件提供程序

manifest.xml

...
 <provider
        android:name="android.support.v4.content.FileProvider"
        android:authorities="com.example.myapp.fileprovider"
        android:exported="true"
        android:grantUriPermissions="false"
        android:permission="com.example.filesvisible.permission.READ" >
        <meta-data
            android:name="android.support.FILE_PROVIDER_PATHS"
            android:resource="@xml/filespath" />
    </provider>
...
。。。
...
从:

false:该提供程序对其他应用程序不可用。设置 android:exported=“false”以限制用户对提供商的访问 应用。仅具有与相同用户ID(UID)的应用程序 提供商将有权访问它

我试图将exported设置为true,但出现了此异常
无法获取提供程序android.support.v4.content.FileProvider:java.lang.SecurityException:不能导出提供程序
为什么无法导出文件提供程序

其他应用程序是否可以使用文件提供程序

对。这通常是重点

为什么我不能导出文件提供程序

因为这不是使用
文件提供程序的方式

FileProvider
背后的要点是。您可以通过
FLAG\u GRANT\u READ\u URI\u PERMISSION
和/或
FLAG\u GRANT\u WRITE\u URI\u PERMISSION
中的
Intent
来实现这一点,您可以使用
Intent
将提供商的
URI
值之一传递给第三方应用程序(例如,通过
操作视图
Intent
startActivity()一起使用)


另请参见。

您好。我使用了你的建议,一切都很好,但当我想使用蓝牙共享声音文件时,出现了一个错误,并说蓝牙已停止。我想这是因为蓝牙没有从我的应用程序文件夹中读取文件的权限。我怎样才能解决这个问题?谢谢。这是我的代码:这是我的代码:sendIntent.setAction(Intent.ACTION\u SEND);sendIntent.putExtra(Intent.EXTRA流,FileProvider.getUriForFile(_上下文,“ir.khazan.ringtone.FileProvider”,newSoundFile在_app_文件夹中));sendIntent.addFlags(Intent.FLAG\授予\读取\ URI\权限);sendIntent.setType(“音频/*”);实用性、活动性、启动性(sendIntent)@卡里姆汗:“我如何解决这个问题?”——使用LogCat检查与其他应用程序关联的Java堆栈跟踪。如果您不理解堆栈溢出,请使用您的代码和堆栈跟踪单独询问一个关于堆栈溢出的问题。