Tengo una aplicacion que genera un PDF, el archivo esta bien, no hay problemas al crearlo el problema es cundo quiero mostrar , se habre el archivo mero me cierra la aplicacion, ayuda
Este es el codigo
En el evento Button llamo:
closeDocumen();
openDocumenView();
donde:
public void closeDocumen(){
document.close();
}
public void openDocumenView(){
//pdfFile.
if (pdfFile.exists()) {
try {
Uri path;
if(Build.VERSION.SDK_INT>=24){
Method m = StrictMode.class.getMethod("disableDeathOnFileUriExposure");
m.invoke(null);
path = FileProvider.getUriForFile(context, BuildConfig.APPLICATION_ID + ".provider",pdfFile);
}else{
path = Uri.fromFile(pdfFile);
}
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(path, "application/pdf");
//intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK |Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_ACTIVITY_NO_HISTORY);
context.startActivity(intent);
}catch (RuntimeException e){
Toast.makeText(context,
"Error : "+ e.getMessage(),
Toast.LENGTH_SHORT).show();
} catch (Exception es){
Toast.makeText(context,
"Error : "+ es.getMessage(),
Toast.LENGTH_SHORT).show();
}
}
}
Estoy usando
implementation 'com.itextpdf:itextg:5.5.10'
El error que me manda es:
E/JavaBinder: !!! FAILED BINDER TRANSACTION !!! (parcel size = 1106680)
D/AndroidRuntime: Shutting down VM
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.administrador.systemaautonica, PID: 16277
java.lang.RuntimeException: android.os.TransactionTooLargeException: data parcel size 1106680 bytes
at android.app.ActivityThread$StopInfo.run(ActivityThread.java:3781)
at android.os.Handler.handleCallback(Handler.java:751)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6119)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
Caused by: android.os.TransactionTooLargeException: data parcel size 1106680 bytes
at android.os.BinderProxy.transactNative(Native Method)
at android.os.BinderProxy.transact(Binder.java:615)
at android.app.ActivityManagerProxy.activityStopped(ActivityManagerNative.java:3636)