iPaulPro / aFileChooser

[DEPRECATED] Android library that provides a file explorer to let users select files on external storage.
Apache License 2.0
1.79k stars 847 forks source link

Add a new method in FileUtils.java and changed the old method createGetContentIntent() #84

Open Alex-ZHOU opened 8 years ago

Alex-ZHOU commented 8 years ago

/* * 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_GETCONTENT); // // 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;
}