Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Not sure if you found the answer you were looking for but this is what I end up going with for the same issue.</p> <pre><code>public void openFileChooser(ValueCallback&lt;Uri&gt; uploadMsg, String acceptType, String capture) { Log.i(TAG, "Opening file chooser for type '" + acceptType + "', capture '" + capture + "'"); // Allows for the camera option within the select window when file select button is clicked File imageStorageDir = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES), "Citizen Mobile"); // Create the storage directory if it does not exist if (! imageStorageDir.exists()){ imageStorageDir.mkdirs(); } File file = new File(imageStorageDir + File.separator + "IMG_" + String.valueOf(System.currentTimeMillis()) + ".jpg"); imageUri = Uri.fromFile(file); final List&lt;Intent&gt; cameraIntents = new ArrayList&lt;Intent&gt;(); final Intent captureIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE); final PackageManager packageManager = getPackageManager(); final List&lt;ResolveInfo&gt; listCam = packageManager.queryIntentActivities(captureIntent, 0); for(ResolveInfo res : listCam) { final String packageName = res.activityInfo.packageName; final Intent i = new Intent(captureIntent); i.setComponent(new ComponentName(res.activityInfo.packageName, res.activityInfo.name)); i.setPackage(packageName); i.putExtra(MediaStore.EXTRA_OUTPUT, imageUri); cameraIntents.add(i); } //Allows for the use of the Galley or Pictures folders to select a file to upload mUploadMessage = uploadMsg; Intent i = new Intent(Intent.ACTION_GET_CONTENT); i.addCategory(Intent.CATEGORY_OPENABLE); i.setType("image/*"); Intent chooserIntent = Intent.createChooser(i,"Image Chooser"); chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, new Parcelable[]{captureIntent}); MainActivity.this.startActivityForResult(chooserIntent, FILECHOOSER_RESULTCODE); } // Required to open the file chooser options in Android 3.0+ public void openFileChooser(ValueCallback&lt;Uri&gt; uploadFileCallback, String acceptType) { Log.i(TAG, "Opening legacy file chooser for type '" + acceptType + "'"); openFileChooser(uploadFileCallback, acceptType, ""); } // Required to open the file chooser options in Android &lt; 3.0 @SuppressWarnings("unused") public void openFileChooser(ValueCallback&lt;Uri&gt; uploadFileCallback) { Log.i(TAG, "Opening very legacy file chooser"); openFileChooser(uploadFileCallback, ""); } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload