Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions android/src/main/java/com/filepicker/FilePickerModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,20 +55,20 @@ public String getName() {
@ReactMethod
public void showFilePicker(final ReadableMap options, final Callback callback) {
Activity currentActivity = getCurrentActivity();
String mimeType = options.hasKey("mimeType") ? options.getString("mimeType") : "*/*";
response = Arguments.createMap();

if (currentActivity == null) {
response.putString("error", "can't find current Activity");
callback.invoke(response);
return;
}

launchFileChooser(callback);
launchFileChooser(callback, mimeType);
}

// NOTE: Currently not reentrant / doesn't support concurrent requests
@ReactMethod
public void launchFileChooser(final Callback callback) {
public void launchFileChooser(final Callback callback, final String mimeType) {
int requestCode;
Intent libraryIntent;
response = Arguments.createMap();
Expand All @@ -82,7 +82,7 @@ public void launchFileChooser(final Callback callback) {

requestCode = REQUEST_LAUNCH_FILE_CHOOSER;
libraryIntent = new Intent(Intent.ACTION_GET_CONTENT);
libraryIntent.setType("*/*");
libraryIntent.setType(mimeType);
libraryIntent.addCategory(Intent.CATEGORY_OPENABLE);

if (libraryIntent.resolveActivity(mReactContext.getPackageManager()) == null) {
Expand Down Expand Up @@ -249,4 +249,4 @@ public static String getDataColumn(Context context, Uri uri, String selection,
return null;
}

}
}