Could not retrieve the image from the clipboard on Android as the app no longer have access due to lifecycle changes #2243
Labels
android
Issues or feature requests specific to the Android platform.
blocked
This issue cannot be resolved due to an obstacle or dependency.
bug
Something isn't working
minor
Minimal impact or cosmetic issue. Can be resolved at a later time without affecting overall function
unplanned
This will not be worked on
Is there an existing issue for this?
Flutter Quill version
Commit 9840745
Steps to reproduce
This issue is on Android only and is platform-specific in the Android JVM.
flutter run
), you might get a crash.The issue can happen on
quill_native_bridge
andsuper_clipboard
(see super_native_extensions #435 for the related issue) implementation.On
super_clipbaord
the Android app can crash, on thequill_native_bridge
implementation introduced in #2230. The plugin will simply returnnull
togetClipboardGif()
orgetClipboardImage
and print a message only on debug mode referencing this issue.The issue is that the app can lose access to the
android.net.Uri
on the clipboard and a workaround (to actually return the image instead of ignoring it) is to save it to a temporary location or somewhere where the image can be accessed on the app restart or lifecycle changes on the next time callinggetClipboardImage
.I had to introduce this workaround instead of fixing it since saving images to the user's device (even if it's specific to the app document directory) is not ideal, the developer or the end user might not want this behavior on their apps/devices.
Expected results
To be able to retrieve the image without this crash/exception.
Once
super_native_extensions
#435 is confirmed and fixed, this will not be an issue for theSuperClipboardService
implementation.The
DefaultClipboardService
will returnnull
and print a message on debug-only mode instead of crashing the app due to an unhandled exception from the Android code side (SecurityException
orFileNotFoundException
fromjava.io
).Actual results
App crashes on
super_clipbaord
implementation. Forquill_native_bridge
caused unhandled exception from the dart side (still not published #2230), updated to simply print a warning and handle it from the dart side and returnnull
, image will not be available and will not have it pasted on the editor.Additional Context
This is tested using
quill_native_bridge
.For
super_clipboard
video refer tosuper_native_extensions
#435Screenshots / Video demonstration
For
super_clipboard
video refer tosuper_native_extensions
#435Screen.Recording.2024-09-18.at.4.53.08.PM.mov
Logs
The text was updated successfully, but these errors were encountered: