私のアンドロイドアプリでは、ユーザーがGoogleフォトアルバムから写真を選択してアプリにアップロードする機能を提供しようとしています。この機能は、Googleの写真からUri
を取得し、その画像をimageview
に表示して、検索したuri
を使用するとうまく機能します。しかし、私は、ユーザーと同じURIがFirebaseストレージに画像をアップロードする際に、次のコード行でアプリがクラッシュ:Firebaseストレージアップロードタスク - コンテンツリゾルバのセキュリティ例外
UploadTask uploadTaskPic = picReference.putFile(picUriLocal);
picUriLocal
は、私は、Googleの写真から受けるウリです。
URI:
The source of the upload. This can be a file:// scheme or any content URI. A content resolver will be used to load the data.
だから私は、なぜセキュリティ例外を把握することはできませんよ、それはと述べてUploadTask
のドキュメントで
12-17 11:31:41.814 18971-18971/me.buddy.buddy E/AndroidRuntime:
FATAL EXCEPTION: main
Process: me.buddy.buddy, PID: 18971
java.lang.SecurityException: Permission Denial: opening provider com.google.android.apps.photos.contentprovider.impl.MediaContentProvider from
ProcessRecord{27fa910 18971:me.buddy.buddy/u0a154} (pid=18971, uid=10154) that is not exported from uid 10057 at android.os.Parcel.readException(Parcel.java:1629) at android.os.Parcel.readException(Parcel.java:1582)
atandroid.app.ActivityManagerProxy.getContentProvider(ActivityManagerNative.java:3598)
at android.app.ActivityThread.acquireProvider(ActivityThread.java:5172)
at android.app.ContextImpl$ApplicationContentResolver.acquireUnstableProvider(ContextImpl.java:2026)
at android.content.ContentResolver.acquireUnstableProvider(ContentResolver.java:1481)
at android.content.ContentResolver.openTypedAssetFileDescriptor(ContentResolver.java:1101)
at android.content.ContentResolver.openAssetFileDescriptor(ContentResolver.java:955) at android.content.ContentResolver.openFileDescriptor(ContentResolver.java:808)at android.content.ContentResolver.openFileDescriptor(ContentResolver.java:762)
at com.google.firebase.storage.UploadTask.<init>(Unknown Source)
at com.google.firebase.storage.StorageReference.putFile(Unknown Source)
at me.buddy.buddy.ui.UserProfile.saveAndClose(UserProfile.java:211)
at me.buddy.buddy.ui.UserProfile.access$000(UserProfile.java:68)
at me.buddy.buddy.ui.UserProfile$1.onClick(UserProfile.java:97)
at android.view.View.performClick(View.java:5232)
at android.view.View$PerformClick.run(View.java:21289)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:168)
at android.app.ActivityThread.main(ActivityThread.java:5885)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:797)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:687)
:下記のエラーのスタックトレース。