My app crashes when trying to open hyperlinks in SfPdfViewer

Hello!

I'm having some issues when trying to open hyperlinks in SfPdfViewer. 

I have the 'AllowHyperlinkNavigation' property set to true and I'm also watching the 'HyperlinkClicked' event. 

The event is getting the correct uri as expected, but my app is crashing when leaving this method. 

It seems that it crashes when trying to open a Dialog. 

Is there any way I can open the hyperlink in browser just with the 'HyperlinkClicked' event, without needing this Dialog?

Let me show the error I'm getting next.

Thanks in advance,
Nilo Basilio


Android.Views.WindowManagerBadTokenException: Unable to add window -- token android.os.BinderProxy@d427582 is not valid; is your activity running?
  at Java.Interop.JniEnvironment+InstanceMethods.CallVoidMethod (Java.Interop.JniObjectReference instance, Java.Interop.JniMethodInfo method, Java.Interop.JniArgumentValue* args) [0x0006e] in :0
  at Java.Interop.JniPeerMembers+JniInstanceMethods.InvokeVirtualVoidMethod (System.String encodedMember, Java.Interop.IJavaPeerable self, Java.Interop.JniArgumentValue* parameters) [0x0002a] in :0
  at Android.App.Dialog.Show () [0x00000] in /Users/builder/azdo/_work/1/s/xamarin-android/src/Mono.Android/obj/Release/monoandroid10/android-30/mcw/Android.App.Dialog.cs:2758
  at Syncfusion.SfPdfViewer.XForms.Droid.LinearLayoutEx.HyperlinkAnnotationButton (System.String annotationUri, Xamarin.Forms.Rectangle annotationBounds, System.Int32 pageIndex) [0x00102] in <3d17a5c6caae4c3f801c757548271008>:0
  at Syncfusion.SfPdfViewer.XForms.Droid.GestureDetectorEx.OnSingleTapConfirmed (Android.Views.MotionEvent e) [0x000f0] in <3d17a5c6caae4c3f801c757548271008>:0
  at Android.Views.GestureDetector+SimpleOnGestureListener.n_OnSingleTapConfirmed_Landroid_view_MotionEvent_ (System.IntPtr jnienv, System.IntPtr native__this, System.IntPtr native_e) [0x00010] in /Users/builder/azdo/_work/1/s/xamarin-android/src/Mono.Android/obj/Release/monoandroid10/android-30/mcw/Android.Views.GestureDetector.cs:1307
  at at (wrapper dynamic-method) Android.Runtime.DynamicMethodNameCounter.121(intptr,intptr,intptr)
  at android.view.WindowManager$BadTokenException: Unable to add window -- token android.os.BinderProxy@d427582 is not valid; is your activity running?
  at at android.view.ViewRootImpl.setView(ViewRootImpl.java:977)
  at at android.view.WindowManagerGlobal.addView(WindowManagerGlobal.java:416)
  at at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:102)
  at at android.app.Dialog.show(Dialog.java:419)
  at at crc64f0d106695cb1f69e.GestureDetectorEx.n_onSingleTapConfirmed(Native Method)
  at at crc64f0d106695cb1f69e.GestureDetectorEx.onSingleTapConfirmed(GestureDetectorEx.java:38)
  at at android.view.GestureDetector$GestureHandler.handleMessage(GestureDetector.java:323)
  at at android.os.Handler.dispatchMessage(Handler.java:107)
  at at android.os.Looper.loop(Looper.java:214)
  at at android.app.ActivityThread.main(ActivityThread.java:7615)
  at at java.lang.reflect.Method.invoke(Native Method)
  at at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
  at at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:964)

7 Replies

MK Muralitharan Karikalan Syncfusion Team June 9, 2021 12:00 PM UTC

Hi Nilo,  
  
Greetings from Syncfusion support,  
  
We were unable to reproduce the issue, “Application crashes with exception while opening a hyperlink in the document” in Xamarin.Forms Android platform and it is working as expected. Could you please try the below-provided sample and let us know whether we have missed out anything while replicating the issue.  
   
Please find the sample in the below link, which we have used to reproduce the issue in our end, 
 
Please find the video where the hyperlinks worked properly, 
  
Kindly share the following details to analyze more on this issue and assist you with the better solution    
1.Simple sample/ modify the above sample to reproduce the issue.   
2.Replication video/procedure to reproduce the issue.  
3.PDF document  
4.SfPdfViewer version 
  
Regards,  
Muralitharan K  



NB Nilo Basilio June 9, 2021 01:19 PM UTC

Hi Muralitharan,

I'm not able to reproduce the issue in this sample, somehow it works properly. However, I found this workaround for my application and it worked:

          void PdfViewerControl_HyperlinkClicked(object sender, Syncfusion.SfPdfViewer.XForms.HyperlinkClickedEventArgs args)
        {
             args.Handled = true;
        }

But there is another issue when testing other pdf, the 'HyperlinkClicked' event are not getting fired. 
I've attached the pdf in the sample, so you can test it. I'm using SfPdfViewer version 19.1.0.66.

Can you test it from your side, please? 

Thanks for the assist,
Nilo Basilio

Attachment: SavePDFUsingNative_50a70ae8.zip


MK Muralitharan Karikalan Syncfusion Team June 10, 2021 07:44 AM UTC

Hi Nilo, 
 
Thanks for your update. We were able to reproduce the issue, “Hyperlinks are not working and Hyperlink clicked event is not triggered in a particular PDF document” . Currently, we are validating this issue and we will update the further details on June 14, 2021. 
 
Regards, 
Muralitharan K 



MK Muralitharan Karikalan Syncfusion Team June 14, 2021 05:39 PM UTC

Hi Nilo, 
 
Sorry for the inconvenience caused. We are still validating the issue, “Hyperlinks are not working and Hyperlink clicked event is not triggered in a particular PDF document” due to its complexity and the issue is involved with one of our dependency (PDF Library). Currently we are working on this as high priority and we will update the validation details on June 16, 2021 without any further delay. 
 
Regards, 
Muralitharan K 



NB Nilo Basilio June 14, 2021 05:49 PM UTC

Hello Muralitharan,

No problem, I really appreciate your help. Thanks for giving this high priority. 

Regards, 
Nilo


MK Muralitharan Karikalan Syncfusion Team June 15, 2021 05:40 AM UTC

Hi Nilo, 
 
Thanks for your patience. As mentioned earlier we will provide the validation details for the issue, “Hyperlinks are not working and Hyperlink clicked event is not triggered in a particular PDF document” on June 16, 2021. 
 
Regards, 
Muralitharan K 



MK Muralitharan Karikalan Syncfusion Team June 16, 2021 08:25 AM UTC

Hi Nilo, 
 
On further analysis, we found that the issue, “Hyperlinks are not working and Hyperlink clicked event is not triggered in a particular PDF document” is not a defect. The URL in the documents are not valid hyperlinks and it is just a text which contains a URL.   
   
Please refer to the below image where the document didn’t contain valid hyperlink annotations    
 
 
 
Other PDF Viewers automatically detect this text as a hyperlink, but at present, there is no support in our SfPdfViewer to automatically detect text in URL format as a hyperlink. Due to this while tapping the hyperlink the clicked event is not raised. We do not have any immediate plans to implement this feature. At the planning stage for every release cycle, we review all open features and identify features for implementation based on specific parameters including product vision, technological feasibility, and customer interest.         
          
Based on our present commitments and the above parameters, this feature is expected to be implemented in our 2021 Volume 4 main release. We will let you know when this feature is implemented.        
       
Disclaimer: The date for the feature implementation is tentative and not a commitment on our parts.         
       
You can now track the status of this feature request here,      
 
Regards, 
Muralitharan K 
 


Loader.
Up arrow icon