Need to utilise the camera in my app for work, I see that things have changed in API >= 28 compared to how I used to do it where I could use startActivityForResult.
However I am facing a problem where I launch the camera app, and immediately get the 'TransactionTooLargeException' error message in the debug/run console.
For calling up the camera, I am doing
mGetContent = registerForActivityResult(
new ActivityResultContracts.TakePicture(),
result -> {
if (result) {
}
}
);
Where mGetContent is defined in the class as
private ActivityResultLauncher<Uri> mGetContent;
In my AndroidManifest.xml file I have the following
<provider
android:name="androidx.core.content.FileProvider"
android:authorities="com.test.fileprovider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/file_paths" />
</provider>
In my file_paths file I have
<?xml version="1.0" encoding="utf-8"?>
<paths xmlns:android="http://schemas.android.com/apk/res/android">
<files-path
name="files"
path="."/>
<files-path
name="app_images"
path="./files/"/>
</paths>
I have a button set up in my activity where I launch the camera using
findViewById(R.id.button)).setOnClickListener(v -> {
File directory = new File(context.getFilesDir(), "app_images");
if (!directory.exists()) directory.mkdir();
File file = new File(directory, "image.jpg");
Uri uri = getUriForFile(this, "com.test.fileprovider", file);
mGetContent.launch(uri);
};
As soon as I tap on the button, and the camera app opens up, I get what I can only assume is an overly general error message.
E/JavaBinder: !!! FAILED BINDER TRANSACTION !!! (parcel size = 1284092)
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.test, PID: 14296
java.lang.RuntimeException: android.os.TransactionTooLargeException: data parcel size 1284092 bytes
at android.app.servertransaction.PendingTransactionActions$StopInfo.run(PendingTransactionActions.java:161)
at android.os.Handler.handleCallback(Handler.java:883)
at android.os.Handler.dispatchMessage(Handler.java:100)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7397)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:935)
Caused by: android.os.TransactionTooLargeException: data parcel size 1284092 bytes
at android.os.BinderProxy.transactNative(Native Method)
at android.os.BinderProxy.transact(BinderProxy.java:511)
at android.app.IActivityTaskManager$Stub$Proxy.activityStopped(IActivityTaskManager.java:4524)
at android.app.servertransaction.PendingTransactionActions$StopInfo.run(PendingTransactionActions.java:145)
Been trying to Google search to find things, but having trouble nailing down what the actual issue is.
Some suggestions pointed me towards the onSaveInstanceState, so I override that and set a breakpoint on it to see what was happening, but it made it through without any issues (from what I could tell).
Kind of at a loss with this one.