how to resolve Could not copy bitmap to parcel blob in android 12

1.7k views Asked by At

I am converting bitmap to File and sending to the server , after response is successful then have go another activity but it getting crash in android 12 but working fine in android 11

E  FATAL EXCEPTION: main
Process: com.docmobil.client, PID: 10829
java.lang.RuntimeException: Could not copy bitmap to parcel blob.
    at android.graphics.Bitmap.nativeWriteToParcel(Native Method)
    at android.graphics.Bitmap.writeToParcel(Bitmap.java:2140)
    at android.os.Parcel.writeParcelable(Parcel.java:2538)
    at android.os.Parcel.writeValue(Parcel.java:2439)
    at android.os.Parcel.writeValue(Parcel.java:2316)
    at android.os.Parcel.writeArrayMapInternal(Parcel.java:1265)
    at android.os.BaseBundle.writeToParcelInner(BaseBundle.java:1802)
    at android.os.Bundle.writeToParcel(Bundle.java:1389)
    at android.os.Parcel.writeBundle(Parcel.java:1334)
    at android.os.Parcel.writeValue(Parcel.java:2433)
    at android.os.Parcel.writeValue(Parcel.java:2323)
    at android.os.Parcel.writeSparseArray(Parcel.java:1422)
    at android.os.Parcel.writeValue(Parcel.java:2463)
    at android.os.Parcel.writeValue(Parcel.java:2316)
    at android.os.Parcel.writeArrayMapInternal(Parcel.java:1265)
    at android.os.BaseBundle.writeToParcelInner(BaseBundle.java:1802)
    at android.os.Bundle.writeToParcel(Bundle.java:1389)
    at android.os.Parcel.writeBundle(Parcel.java:1334)
    at android.os.Parcel.writeValue(Parcel.java:2433)
    at android.os.Parcel.writeValue(Parcel.java:2323)
    at android.os.Parcel.writeArrayMapInternal(Parcel.java:1265)
    at android.os.BaseBundle.writeToParcelInner(BaseBundle.java:1802)
    at android.os.Bundle.writeToParcel(Bundle.java:1389)
    at android.os.Parcel.writeTypedObject(Parcel.java:2157)
    at android.app.IActivityClientController$Stub$Proxy.activityStopped(IActivityClientController.java:1277)
    at android.app.ActivityClient.activityStopped(ActivityClient.java:86)
    at android.app.servertransaction.PendingTransactionActions$StopInfo.run(PendingTransactionActions.java:143) 
    at android.os.Handler.handleCallback(Handler.java:942)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loopOnce(Looper.java:201)
    at android.os.Looper.loop(Looper.java:288)
    at android.app.ActivityThread.main(ActivityThread.java:7872)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:936)
    @Throws(IOException::class)
    private fun convertBitmapToFile(bitmap: Bitmap): File {
        val wrapper = ContextWrapper(this)
        var file = wrapper.getDir("Images", Context.MODE_PRIVATE)
        file = File(file, "${userName}_signature.jpg")
        val byteArrayOutputStream = ByteArrayOutputStream()
        bitmap.compress(Bitmap.CompressFormat.JPEG, 80, byteArrayOutputStream)
        val stream: OutputStream = FileOutputStream(file)
        stream.flush()
        stream.close()
        val i = Intent(this@DisclosureActivity, DoctorInfoAct::class.java)
        startActivity(i)
        return file
    }

Want to go another activity after file upload but the main issue because of when go to another activity it getting crash but, if I do not do any other operation then it's ok no crashing , But need to go another activity in android latest version 12,13..

0

There are 0 answers