Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I suppose that the <code>onActivityResult</code> method is actually called, but the 3rd parameter <code>Intent intent</code> is null. It seems that it is a bug of Nexus phones.</p> <p>But you can save the output image uri to the private variable and use it instead of the intent:</p> <pre><code>private Uri imageUri; private void showAttachmentDialog(ValueCallback&lt;Uri&gt; uploadMsg) { this.mUploadMessage = uploadMsg; File imageStorageDir = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES), "TestApp"); if (!imageStorageDir.exists()) { imageStorageDir.mkdirs(); } File file = new File(imageStorageDir + File.separator + "IMG_" + String.valueOf(System.currentTimeMillis()) + ".jpg"); this.imageUri = Uri.fromFile(file); // save to the private variable final Intent captureIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE); captureIntent.putExtra(MediaStore.EXTRA_OUTPUT, imageUri); 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 }); this.startActivityForResult(chooserIntent, FILECHOOSER_RESULTCODE); } @Override protected void onActivityResult(int requestCode, int resultCode, Intent intent) { if (requestCode == FILECHOOSER_RESULTCODE) { if (null == this.mUploadMessage) { return; } Uri result; if (resultCode != RESULT_OK) { result = null; } else { result = intent == null ? this.imageUri : intent.getData(); // retrieve from the private variable if the intent is null } this.mUploadMessage.onReceiveValue(result); this.mUploadMessage = null; } } </code></pre> <p>In this code I added the <code>imageUri</code> variable to the activity and used it in both methods.</p>
    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.
 

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