0
I’m having problems in a routine to take pictures, simple routine that in Android 4.1 a 6.0 no longer have problem in 7 while trying to take a photo for the app, tried everything a week ago trying, looking for this problem in forums, more I’m almost giving up because I don’t see more where I can look and so see if anyone has been through 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 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();
}
}