There are lines in the code
camera.takePicture(null, null, new PictureCallback() { @Override public void onPictureTaken(byte[] data, Camera camera) {.....делаем фото.....}
Next comes the code that is not associated with the camera. Various actions. And at the end of the code I open another layout.
The problem is that the code that is not associated with the camera is processed, the layout is opened .. And only then the Callback
processed
Since the new layout overlaps the surfaceView
snapshot cannot be done. And I need it =)
Code snippet:
try { GetPic(); } catch (IOError e) {} Thread.currentThread(); Thread.sleep(500); Intent intent = new Intent() .setClass(MainActivity.this, mail.class); startActivityForResult(intent, 1); TextForFile = TextForFile + "Photo_" + date2+ ".jpg"+";"; //запись текстового файла try { OutputStream ToRecordsFile; ToRecordsFile=new FileOutputStream(photoFile + File.separator+"r.csv",true); OutputStreamWriter sw=new OutputStreamWriter(ToRecordsFile); sw.write(TextForFile); sw.close();//Закрыли } catch (IOException e) { Log.e("MyError", "Не создался writer", e); } //запись текстового файла ////////////////////////////////////////////////////
GetPic () function:
private void GetPic() { try { camera.takePicture(null, null, new PictureCallback() { @Override public void onPictureTaken(byte[] data, Camera camera) {try { FileOutputStream fos = new FileOutputStream(pictureFile); fos.write(data); fos.close(); } catch (Exception e) { e.printStackTrace(); }} }); } catch(Exception e) {}