public void savePicture(Context context) {
    byte[] result = mAlmaCLRShot.processingSaveData();
    int frame_len = result.length;
    int frame = SwapHeap.SwapToHeap(result);

    PluginManager.getInstance()
        .addToSharedMem("resultframeformat1" + Long.toString(sessionID), "jpeg");
    PluginManager.getInstance()
        .addToSharedMem("resultframe1" + Long.toString(sessionID), String.valueOf(frame));
    PluginManager.getInstance()
        .addToSharedMem("resultframelen1" + Long.toString(sessionID), String.valueOf(frame_len));

    PluginManager.getInstance()
        .addToSharedMem(
            "resultframeorientation1" + String.valueOf(sessionID),
            String.valueOf(mDisplayOrientation));
    PluginManager.getInstance()
        .addToSharedMem(
            "resultframemirrored1" + String.valueOf(sessionID), String.valueOf(mCameraMirrored));

    PluginManager.getInstance()
        .addToSharedMem("amountofresultframes" + Long.toString(sessionID), String.valueOf(1));

    PluginManager.getInstance().addToSharedMem("sessionID", String.valueOf(sessionID));
    mAlmaCLRShot.release();
  }
  public void savePicture(Context context) {
    byte[] result = mAlmaCLRShot.processingSaveData();
    int frame_len = result.length;
    int frame = SwapHeap.SwapToHeap(result);

    PluginManager.getInstance().addToSharedMem("resultframeformat1" + sessionID, "jpeg");
    PluginManager.getInstance().addToSharedMem("resultframe1" + sessionID, String.valueOf(frame));
    PluginManager.getInstance()
        .addToSharedMem("resultframelen1" + sessionID, String.valueOf(frame_len));

    // Nexus 6 has a original front camera sensor orientation, we have to manage it
    PluginManager.getInstance()
        .addToSharedMem(
            "resultframeorientation1" + sessionID,
            String.valueOf(
                (Build.MODEL.contains("Nexus 6") && mCameraMirrored)
                    ? (mDisplayOrientation + 180) % 360
                    : mDisplayOrientation));
    PluginManager.getInstance()
        .addToSharedMem("resultframemirrored1" + sessionID, String.valueOf(mCameraMirrored));

    PluginManager.getInstance()
        .addToSharedMem("amountofresultframes" + sessionID, String.valueOf(1));

    PluginManager.getInstance().addToSharedMem("sessionID", String.valueOf(sessionID));
    mAlmaCLRShot.release();
  }
  @Override
  public void onPictureTaken(byte[] paramArrayOfByte, Camera paramCamera) {
    imagesTaken++;
    int frame_len = paramArrayOfByte.length;
    int frame = SwapHeap.SwapToHeap(paramArrayOfByte);

    if (frame == 0) {
      Log.i("Burst", "Load to heap failed");
      Message message = new Message();
      message.obj = String.valueOf(SessionID);
      message.what = PluginManager.MSG_CAPTURE_FINISHED;
      MainScreen.H.sendMessage(message);

      imagesTaken = 0;
      MainScreen.thiz.MuteShutter(false);
      inCapture = false;
      return;
    }
    String frameName = "frame" + imagesTaken;
    String frameLengthName = "framelen" + imagesTaken;

    PluginManager.getInstance()
        .addToSharedMem(frameName + String.valueOf(SessionID), String.valueOf(frame));
    PluginManager.getInstance()
        .addToSharedMem(frameLengthName + String.valueOf(SessionID), String.valueOf(frame_len));
    PluginManager.getInstance()
        .addToSharedMem(
            "frameorientation" + imagesTaken + String.valueOf(SessionID),
            String.valueOf(MainScreen.guiManager.getDisplayOrientation()));
    PluginManager.getInstance()
        .addToSharedMem(
            "framemirrored" + imagesTaken + String.valueOf(SessionID),
            String.valueOf(MainScreen.getCameraMirrored()));

    if (imagesTaken == 1)
      PluginManager.getInstance().addToSharedMem_ExifTagsFromJPEG(paramArrayOfByte, SessionID);

    try {
      paramCamera.startPreview();
    } catch (RuntimeException e) {
      Log.i("Burst", "StartPreview fail");
      Message message = new Message();
      message.obj = String.valueOf(SessionID);
      message.what = PluginManager.MSG_CAPTURE_FINISHED;
      MainScreen.H.sendMessage(message);

      imagesTaken = 0;
      MainScreen.thiz.MuteShutter(false);
      inCapture = false;
      return;
    }
    if (imagesTaken < imageAmount) MainScreen.H.sendEmptyMessage(PluginManager.MSG_TAKE_PICTURE);
    else {
      PluginManager.getInstance()
          .addToSharedMem(
              "amountofcapturedframes" + String.valueOf(SessionID), String.valueOf(imagesTaken));

      Message message = new Message();
      message.obj = String.valueOf(SessionID);
      message.what = PluginManager.MSG_CAPTURE_FINISHED;
      MainScreen.H.sendMessage(message);

      imagesTaken = 0;
      inCapture = false;
    }
    takingAlready = false;
  }