Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid: Not able to call onActivityResult() method after capturing photo by camera
    primarykey
    data
    text
    <p>In my application when I call camera intent by:</p> <pre><code>Intent cameraIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); startActivityForResult(cameraIntent, CAMERA_REQUEST); </code></pre> <p>it not call <code>onActivityResult()</code> method.</p> <p>Problem in my application is that some time it calls this method, but some time after capturing photo it again come to photo capture screen.</p> <p>Before capturing photo I am saving a lot of data in <code>onSaveInstanceState()</code> after that I am collecting this data by <code>onRestoreInstanceState()</code>.</p> <p>Here I don't know why some time <code>onActivityResult()</code> method calls but some time this method does not call after entering into the photo capture mode.</p> <p>onActivityResult() code:</p> <pre><code>@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); String fileName = null; try { if (requestCode == CAMERA_REQUEST) { roughBitmap = (Bitmap) data.getExtras().get("data"); final ContentResolver cr = getContentResolver(); final String[] p1 = new String[] { MediaStore.Images.ImageColumns._ID, MediaStore.Images.ImageColumns.DATE_TAKEN }; Cursor c1 = cr.query( MediaStore.Images.Media.EXTERNAL_CONTENT_URI, p1, null, null, p1[1] + " DESC"); if (c1.moveToFirst()) { String uristringpic = "content://media/external/images/media/" + c1.getInt(0); newuri = Uri.parse(uristringpic); // Log.i("TAG", "newuri "+newuri); snapName = getRealPathFromURI(newuri); Uri u = Uri.parse(snapName); File f = new File("" + u); fileName = f.getName(); } c1.close(); setImageParameter(); } } catch (NullPointerException e) { } System.out.println("*** End of onActivityResult() ***"); } public void setImageParameter() { // decode full image roughBitmap = BitmapFactory.decodeFile(snapName); // calc exact destination size Matrix matrix = new Matrix(); RectF inRect = new RectF(0, 0, roughBitmap.getWidth(), roughBitmap.getHeight()); // RectF outRect = new RectF(0, 0, dstWidth, dstHeight); RectF outRect = new RectF(0, 0, 640, 480); matrix.setRectToRect(inRect, outRect, Matrix.ScaleToFit.CENTER); float[] values = new float[9]; matrix.getValues(values); // resize bitmap resizedBitmap = Bitmap.createScaledBitmap(roughBitmap, (int) (roughBitmap.getWidth() * values[0]), (int) (roughBitmap.getHeight() * values[4]), true); paint = new Paint(); paint.setColor(Color.GREEN); paint.setTextSize(16); paint.setTextAlign(Paint.Align.LEFT); Canvas canvas = new Canvas(resizedBitmap); canvas.drawText(String.valueOf(lat), resizedBitmap.getWidth() - 290, resizedBitmap.getHeight() - 50, paint); canvas.drawText(String.valueOf(lng), resizedBitmap.getWidth() - 140, resizedBitmap.getHeight() - 50, paint); if (!editTextRoadName.getText().toString().equalsIgnoreCase("")) { canvas.drawText(editTextRoadName.getText().toString(), resizedBitmap.getWidth() - 290, resizedBitmap.getHeight() - 30, paint); } canvas.drawText(new DateClass().getSysDateTimeForPhoto(), resizedBitmap.getWidth() - 290, resizedBitmap.getHeight() - 10, paint); if (nFinalOrientation == 1) { matrix.postRotate(90); } else { matrix.postRotate(0); } rotatedBitmap = Bitmap.createScaledBitmap(resizedBitmap, (int) (resizedBitmap.getWidth() * values[0]), (int) (resizedBitmap.getHeight() * values[4]), true); if (booleanPhotoFlag) { booleanPhotoFlag = false; photoBitmap = rotatedBitmap.copy(Bitmap.Config.ARGB_8888, true); imageViewPhoto.setImageBitmap(photoBitmap); } else { landmarkBitmap = rotatedBitmap.copy(rotatedBitmap.getConfig(), rotatedBitmap.isMutable() ? true : false); imageViewLocationPhoto.setImageBitmap(landmarkBitmap); } } </code></pre>
    singulars
    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.
 

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