/// <summary> /// Get selected image from gallery. /// </summary> protected internal override void onActivityResult(int requestCode, int resultCode, Intent data) { base.onActivityResult(requestCode, resultCode, data); if (resultCode == RESULT_OK) { if (requestCode == SELECT_PICTURE) { Uri selectedImageUri = data.Data; if (!ContentResolver.getType(selectedImageUri).Equals("image/jpeg")) { Toast.makeText(this, "Only support JPEG file.", Toast.LENGTH_LONG).show(); return; } string imagePath = getPath(selectedImageUri); if (imagePath == null) { Log.d(TAG, "imagepath from getPath null"); // get the id of the image selected by the user string wholeID = DocumentsContract.getDocumentId(data.Data); string id = wholeID.Split(":", true)[1]; string[] projection = new string[] { MediaStore.Images.Media.DATA }; string whereClause = MediaStore.Images.Media._ID + "=?"; Cursor cursor = ContentResolver.query(Uri, projection, whereClause, new string[] { id }, null); if (cursor != null) { int column_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA); if (cursor.moveToFirst()) { imagePath = cursor.getString(column_index); } cursor.close(); } else { imagePath = selectedImageUri.Path; Toast.makeText(this, imagePath, Toast.LENGTH_LONG).show(); } } Log.d(TAG, "selected file path " + imagePath); if (mInputImage != null) { mInputImage.release(); } //Make SImage from selected Image and show to Screen. mInputImage = new SCameraImage(imagePath, SCameraImage.FORMAT_DEFAULT); mInputBitmap = getOutputBitmap(mInputImage); if (mInputBitmap == null) { makeBufferWithDefaultPath(); } else { mInputView.ImageBitmap = mInputBitmap; } mOutputView.ImageBitmap = null; } } }