Loosing created annotation on orientation change

Product: PDFTron Android SDK

Product Version: Demo

Please give a brief summary of your issue: Loosing created annotation on orientation change
(Think of this as an email subject)

Is there any way to handle created annotation retain while orientation change?

Please describe your issue and provide steps to reproduce it:
(The more descriptive your answer, the faster we are able to help you)

Please provide a link to a minimal sample where the issue is reproducible:

Hello, I’m Ron, an automated tech support bot :robot:

While you wait for one of our customer support representatives to get back to you, please check out some of these documentation pages:

Guides:APIs:Forums:

Hi Manoj,

I’m not quite following what exactly you are trying to achieve. Is there a video or image mockup so we can better understand what you are trying to do?

Thanks.

Hi,

I have attached the recording. Please look into it.
My query is,
I do not want to loose newly added annotation while changing orientation. Is there any way to handle this?

Hi Manoj, based on your other ticket, I believe you are using custom relative layout to draw the red icon, is that correct? Would it be possible if you could share us a sample project so we can take a look? You can also try to re-add the view on orientation change. Thanks.

Hi Shirley,

Yes, i am using CustomRelativeLayout to draw custom view.
I Observed, Newly added annotation along with custom view is getting loss when orientation changes.
I have shared recording along with sample code. Please have a look.

Hi, the problem is you are not handling orientation change or saving the document. So on rotation, the activity re-starts, and everything you did previously is gone.

2 ways:

Approach 1. handle orientation in your Activity manifest:

<activity
            android:name=".PdfFragmentActivity"
            android:theme="@style/PDFTronAppTheme"
            android:configChanges="keyboardHidden|orientation|screenSize|screenLayout|smallestScreenSize"
            android:windowSoftInputMode="adjustPan"/>

Approach 2. let the activity restart, but you will save PDFDoc on pause, for the custom layout, you will need to re-add it on resume

I’d recommend approach 1 unless you have some special requirement to not handle orientation. Thanks.