lubritto / pdf_viewer_plugin

A Flutter plugin for IOS and Android providing a simple way to display PDFs.
MIT License
57 stars 65 forks source link

Calling startActivity() from outside of an Activity context requires the FLAG_ACTIVITY_NEW_TASK flag - Android 10 #45

Open mdmota opened 4 years ago

mdmota commented 4 years ago

Flutter 1.22.3 Android 10 pdf_viewer_plugin: ^1.0.0+2

Fatal Exception: android.util.AndroidRuntimeException: Calling startActivity() from outside of an Activity context requires the FLAG_ACTIVITY_NEW_TASK flag. Is this really what you want? at android.app.ContextImpl.startActivity(ContextImpl.java:995) at android.app.ContextImpl.startActivity(ContextImpl.java:971) at android.content.ContextWrapper.startActivity(ContextWrapper.java:389) at android.content.ContextWrapper.startActivity(ContextWrapper.java:389) at android.content.ContextWrapper.startActivity(ContextWrapper.java:389) at com.github.barteksc.pdfviewer.link.DefaultLinkHandler.handleUri(DefaultLinkHandler.java:52) at com.github.barteksc.pdfviewer.link.DefaultLinkHandler.handleLinkEvent(DefaultLinkHandler.java:41) at com.github.barteksc.pdfviewer.listener.Callbacks.callLinkHandler(Callbacks.java:177) at com.github.barteksc.pdfviewer.DragPinchManager.checkLinkTapped(DragPinchManager.java:110) at com.github.barteksc.pdfviewer.DragPinchManager.onSingleTapConfirmed(DragPinchManager.java:73) at android.view.GestureDetector$GestureHandler.handleMessage(GestureDetector.java:345) at android.os.Handler.dispatchMessage(Handler.java:107) at android.os.Looper.loop(Looper.java:237) at android.app.ActivityThread.main(ActivityThread.java:8167) at java.lang.reflect.Method.invoke(Method.java) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:496) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1100)

mdmota commented 3 years ago

Complementing to make it easier to track the problem: When displaying the pdf on the screen with the plugin and clicking on a link inside the pdf, the application crash. The problem always happens on Android 10. In other versions of android and ios it does not happen.

I need a solution. If I have no alternative I will look for another plugin

mdmota commented 3 years ago

@lubritto

myselfuser1 commented 1 year ago

This will help https://www.youtube.com/watch?v=gAUVz0U7eyA