Android: some intentional add-ons prevent shutdown

I have an activity that allows me to take an image from the camera, and I want to send this image to the parent activity as an add-on. However, if I'm really trying to add an image to an intent, suddenly the finish() call never does anything, and my activity never closes.

Here are some of my codes:

  public void onPictureTaken(byte[] imageData, Camera c) { if (imageData != null) { // Send the result as a byte array Intent intent = new Intent(); intent.putExtra("imagedata", imageData); setResult(RESULT_OK, intent); finish(); } } 

The odd thing is, if I comment on the call to putExtra() , then everything works correctly (without an image, of course), and my activity closes, and I fall into the parent's onActivityResult() callback. But if I leave the line, then the activity never closes and the callback never fires.

I tried putting more trivial things in add-ons such as strings, and it all worked fine. putExtra() allowed to accept a byte array, and I even tried to wrap it as a bitmap and send it, but it doesn't work either. The only thing I can think of is that I simply should not transfer something big in intention, and in this case, I think, I just try to write it to a file. It's just that writing to a file should be slower than just passing a reference to an array of bytes, so I'm trying to do it this way.

Any ideas? Thanks in advance:)

Phone: Samsung Galaxy S API Level: 7

0
source share
2 answers

You should not include your image data in addition to Intent. See this topic for further details. In short, keep your extra intentions as small as possible.

I would suggest saving the image to an SD card and transferring the path to this file in your intention.

+2
source

try this code

 public void quit() { int pid = android.os.Process.myPid(); android.os.Process.killProcess(pid); System.exit(0); } 

and name it using the quit () function;

0
source

All Articles