There is a code that receives a photo from the camera:
public byte[] i3; ... Camera i1 = Camera.open(CameraInfo.CAMERA_FACING_BACK); Parameters i2 = i1.getParameters(); i2.setPictureSize(...); i1.setParameters(i2); i1.setPreviewTexture(new SurfaceTexture(0)); i1.startPreview(); i1.takePicture(null, null, new PictureCallback() { @Override public void onPictureTaken(byte[] i1, Camera i2) { i3 = i1.clone(); i2.release(); } }); And there is a code that draws an inscription on it:
Bitmap i5 = BitmapFactory.decodeByteArray(i3.toByteArray(), 0, i3.toByteArray().length).copy(Config.ARGB_8888, true); Canvas i6 = new Canvas(i5); ... On the emulator, everything works fine, as on my new Android 4.2.2 phone, but not on the old Android 4.0 phone. There just crashes
In the app ... an error occurred
and nothing else happens. I have completely transferred all my code, Activity whole Activity to a try {} catch (Exception e1) {} - it is useless. Then I connected the phone to a computer and saw via USB debugging in the logs that this line crashes:
Bitmap i5 = BitmapFactory.decodeByteArray(i3.toByteArray(), 0, i3.toByteArray().length).copy(Config.ARGB_8888, true); However, I made sure several times that I also returned it to try {} catch (Exception e1) {} . Unfortunately, in the logs it was not written what kind of exception was thrown, a line was just written, something of the following type:
in my.package.MyActivity.Thread.run() on line 67... in red. Subsequently, I found out that the problem is in the copy(...) method. If I removed it, another error took off telling that it was impossible to draw on Canvas , whose Bitmap is not mutable . How to be? Help correct the error. On the Internet, I did not find a similar problem.
Note. From the first time the picture is perfect and no errors occur. As soon as I try to draw something again in the second new photo, the application crashes. Maybe there is a problem in the lack of memory?
10-10 22:45:05.239: I/dalvikvm(19087): at my.package.MyActivity$1$1.run(MyActivity.java:140). Line 140 saysBitmap i5 = BitmapFactory.decodeByteArray(i3.toByteArray(), 0, i3.toByteArray().length).copy(Config.ARGB_8888, true);. More from this application is not written anything. There are only a few lines in whichActivity read to stop... stopping... exit pid..., that is, a log from the system itself. I am 100% sure that in these logs there is no important information. - nick