Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

fix(android) : App can crash on clipboard.read if empty #2815

Merged
merged 2 commits into from
Apr 29, 2020
Merged

fix(android) : App can crash on clipboard.read if empty #2815

merged 2 commits into from
Apr 29, 2020

Conversation

jrdnp
Copy link
Contributor

@jrdnp jrdnp commented Apr 22, 2020

I encountered app crash when reading the content of the clipboard since 2.0.0+
It only occurs on Android platform and in my case on a Samsung with Android 7.
When my clipboard is empty (like after a reboot) and I attempt to read it, the plugin crashes the app because of a NullPointerException.
I checked the Android documentation and found the method hasPrimaryClip().
So I implemented it in order to check if the primary clip exists. If it's the case, normal behavior happen otherwise the clipboard content will be set to an empty string.

@jrdnp jrdnp changed the title Fix app crash if clipboard was empty on some Android devices fix(android/clipboard) : App can crash if clipboard is empty on some Android devices Apr 23, 2020
@jrdnp jrdnp changed the title fix(android/clipboard) : App can crash if clipboard is empty on some Android devices fix(android/clipboard) : App can crash if clipboard is empty on some devices Apr 23, 2020
@jcesarmobile jcesarmobile changed the title fix(android/clipboard) : App can crash if clipboard is empty on some devices fix(android) : App can crash on clipboard.read if empty Apr 29, 2020
Copy link
Member

@jcesarmobile jcesarmobile left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did the changes myself because I'm doing a release and this was important to be included.

Thanks for the PR!

@jcesarmobile jcesarmobile merged commit fc33265 into ionic-team:master Apr 29, 2020
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants