I'm having problems in a routine to take pictures, simple routine that in Android 4.1 to 6.0 has no problem more at 7 when trying to take a photo for the app, tried everything a week ago trying, looking for this problem in forums , but I almost quit because I can not see where else I can look and see if anyone has ever had this problem.
The error is this
java.lang.RuntimeException: android.os.TransactionTooLargeException: data parcel size 1387072 bytes at
android.app.ActivityThread$StopInfo.run(ActivityThread.java:3781)
at android.os.Handler.handleCallback(Handler.java:751)
The code for the photo is the same as the one we found in tutorials
private void takePicture() {
Log.i(TAG, "takePicture()");
FirebaseCrash.log(TAG + " takePicture()");
Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
if (takePictureIntent.resolveActivity(getActivity().getPackageManager()) != null) {
arquivoFoto = getOutputMediaFile();
if (arquivoFoto != null) {
//Uri fotoURI = Uri.fromFile(arquivoFoto);
Uri fotoURI = FileProvider.getUriForFile(getActivity(),
getActivity().getApplicationContext().getPackageName() + ".provider",
arquivoFoto);
takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, fotoURI);
startActivityForResult(takePictureIntent, PICK_FROM_CAMERA);
}
}
FirebaseCrash.log(TAG + " takePicture() - pickImage()");
FirebaseCrash.log(TAG + " takePicture() - Fim");
}
private File getOutputMediaFile(){
Log.i(TAG, "getOutputMediaFile()");
String appName = Helper.getAppName(getActivity());
File mediaStorageDir = new File(Environment.getExternalStoragePublicDirectory(
Environment.DIRECTORY_PICTURES), appName);
Log.i(TAG, "getOutputMediaFile() - pasta " + mediaStorageDir.toString());
if (!mediaStorageDir.exists()){
if (!mediaStorageDir.mkdirs()){
return null;
}
}
String timeStamp = UUID.randomUUID().toString();
File imagem = new File(mediaStorageDir.getPath() + File.separator +
timeStamp + ".jpg");
mCurrentPhotoPath = imagem.getAbsolutePath();
Log.i(TAG, "getOutputMediaFile() - mCurrentPhotoPath: " + mCurrentPhotoPath);
return imagem;
}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
Log.i(TAG, "onActivityResult()");
FirebaseCrash.log(TAG + " onActivityResult()");
if (requestCode == PICK_FROM_CAMERA && resultCode == RESULT_OK) {
salvarFoto();
}
}