Skip to content

Instantly share code, notes, and snippets.

@marwinxxii
Created September 16, 2013 07:06
Show Gist options
  • Save marwinxxii/6577472 to your computer and use it in GitHub Desktop.
Save marwinxxii/6577472 to your computer and use it in GitHub Desktop.
//imports
//webchromeclient for input type=file with file selector
public class CustomWebChromeClient extends WebChromeClient {
@SuppressWarnings("unused")
public void openFileChooser(ValueCallback<Uri> uploadMsg) {
mUploadMessage = uploadMsg;
Intent i = new Intent(Intent.ACTION_GET_CONTENT);
i.addCategory(Intent.CATEGORY_OPENABLE);
i.setType("image/*");
startActivityForResult(Intent.createChooser(i, "Choose image"), 1);
}
@SuppressWarnings("unused")
public void openFileChooser(ValueCallback<Uri> uploadMsg, String acceptType) {
mUploadMessage = uploadMsg;
Intent i = new Intent(Intent.ACTION_GET_CONTENT);
i.addCategory(Intent.CATEGORY_OPENABLE);
i.setType("*/*");
startActivityForResult(Intent.createChooser(i, "File Browser"), 1);
}
// For Android 4.1
@SuppressWarnings("unused")
public void openFileChooser(ValueCallback<Uri> uploadMsg, String acceptType, String capture){
mUploadMessage = uploadMsg;
Intent i = new Intent(Intent.ACTION_GET_CONTENT);
i.addCategory(Intent.CATEGORY_OPENABLE);
i.setType("image/*");
startActivityForResult(Intent.createChooser(i, "File Chooser"), 1);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment