Tôi đã cố gắng theo dõi Android tutorial trên các tệp chia sẻ. tôi thiết lập các FileProvider
như thế này:IllegalArgumentException: Không thể tìm thấy cấu hình gốc chứa xxx trên FileProvider.getUriForFile
Trên xml biểu hiện chính:
<provider
android:name="android.support.v4.content.FileProvider"
android:authorities="com.example.mysecondapp.fileprovider"
android:exported="false"
android:grantUriPermissions="true" >
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/filepaths" />
</provider>
file res/xml/filpaths.xml:
<paths xmlns:android="http://schemas.android.com/apk/res/android">
<external-path name="myexternalimages" path="SpCars_album/" />
</paths>
Và trong mã của tôi, tôi đang cố gắng như sau:
File requestFile = new File(mImageFilenames[position]);
try {
fileUri = FileProvider.getUriForFile(
SeventhActivity.this,
"com.example.mysecondapp.fileprovider",
requestFile);
} catch (IllegalArgumentException e) {
Log.e("File Selector",
"The selected file can't be shared: " +
mImageFilenames[position]);
}
RequestFile được khởi tạo với đúng đường dẫn làm việc cho một tệp. Đường dẫn của tệp đó bắt đầu chính xác với những gì getExternalFilesDir(Environment.DIRECTORY_PICTURES)
trả về. Tôi không thể hiểu điều gì làm tăng lỗi vì mọi thứ dường như phù hợp. Cảm ơn trước.
bạn có thể cung cấp đầu ra logcat hoàn chỉnh không? – bbuecherl
Đây là bản ghi đầy đủ: http://pastebin.com/xbyMewHc – AndroidNewbie