Skip to content
This repository was archived by the owner on Mar 30, 2022. It is now read-only.

Conversation

@Alex-ZHOU
Copy link

/**
* Get the Intent for selecting content to be used in an Intent Chooser.
*
* @return The intent for opening a file with Intent.createChooser()
* @author paulburke
/
public static Intent createGetContentIntent() {
// // Implicitly allow the user to select a particular kind of data
// final Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
// // The MIME data type filter
// intent.setType("
/*");
// // Only return URIs that can be opened with ContentResolver
// intent.addCategory(Intent.CATEGORY_OPENABLE);
// return intent;
return createGetContentIntent(null);
}

/**
 * Get the Intent for selecting content to be used in an Intent Chooser.
 *
 * @param type Set the type for intent.
 * @return The intent for opening a file with Intent.createChooser()
 * @author AlexZHOU
 */
public static Intent createGetContentIntent(final String type) {
    // Implicitly allow the user to select a particular kind of data
    final Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
    // The MIME data type filter
    intent.setType(type != null ? type : "*/*");
    // Only return URIs that can be opened with ContentResolver
    intent.addCategory(Intent.CATEGORY_OPENABLE);
    return intent;
}

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant