Skip to content Skip to sidebar Skip to footer

Why Doesn't The Google Drive App On Android Send File:// Uris Anymore?

Google Drive used to send file:// URIs as the data for ACTION_VIEW intents. It now sends content:// URIs instead. Why did this change?

Solution 1:

As of Feb 17th 2016, the Drive Apps no longer sends file:// URIs to other apps. This was done to improve security and has been encouraged by Android since 2013.

Content URIs can be resolved to a ParcelFileDescriptor using ContentResolver as shown:

Intentintent= getIntent();
if (Intent.ACTION_VIEW.equals(intent.getAction()) {
    UriincomingData= getIntent().getData();
    ParcelFileDescriptorpfd=
        getContentResolver().openFileDescriptor(incomingData, "r");
    // Use file ...
}

Additionally, apps should no longer use intent filters that restrict the URI to the file scheme:

<intent-filter><actionandroid:name="android.intent.action.VIEW" /><dataandroid:scheme="file"/><!-- Drive will not show this app --></intent-filter>

Mime-type and other filters will continue to work and are encouraged:

<intent-filter><actionandroid:name="android.intent.action.VIEW" /><dataandroid:mimeType="video/mpeg"/></intent-filter>

More information about file sharing and content URIs can be found at developer.android.com.

Post a Comment for "Why Doesn't The Google Drive App On Android Send File:// Uris Anymore?"