Skip to content

Commit 91d0548

Browse files
committed
Storage permissions
Change-Id: I9dd25e5d9e70a0fc3ee4306fe7cc0ee50f8a4cf9
1 parent 2883a35 commit 91d0548

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

storage/app/src/main/java/com/google/firebase/quickstart/firebasestorage/MainActivity.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ private void launchCamera() {
209209
Log.d(TAG, "launchCamera");
210210

211211
// Pick an image from storage
212-
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
212+
Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT);
213213
intent.setType("image/*");
214214
startActivityForResult(intent, RC_TAKE_PICTURE);
215215
}

storage/app/src/main/java/com/google/firebase/quickstart/firebasestorage/MyUploadService.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import android.content.Intent;
44
import android.content.IntentFilter;
55
import android.net.Uri;
6+
import android.os.Build;
67
import android.os.IBinder;
78
import android.support.annotation.NonNull;
89
import android.support.annotation.Nullable;
@@ -58,6 +59,14 @@ public int onStartCommand(Intent intent, int flags, int startId) {
5859
Log.d(TAG, "onStartCommand:" + intent + ":" + startId);
5960
if (ACTION_UPLOAD.equals(intent.getAction())) {
6061
Uri fileUri = intent.getParcelableExtra(EXTRA_FILE_URI);
62+
63+
// Make sure we have permission to read the data
64+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
65+
getContentResolver().takePersistableUriPermission(
66+
fileUri,
67+
Intent.FLAG_GRANT_READ_URI_PERMISSION);
68+
}
69+
6170
uploadFromUri(fileUri);
6271
}
6372

0 commit comments

Comments
 (0)