Skip to content

fix(haptics): Crash on Android API level under 29 #508

New issue

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

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

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 9, 2023

Conversation

asharghi
Copy link
Contributor

@asharghi asharghi commented Jun 9, 2023

Haptics will crash Android devices on version 9 because some of the constants used was not added before sdk version 29. Added a sdk version check

Example of constant: https://developer.android.com/reference/android/os/VibrationEffect#EFFECT_CLICK

@cla-bot cla-bot bot added the cla: yes label Jun 9, 2023
@CatchABus
Copy link
Contributor

CatchABus commented Jun 9, 2023

@asharghi Very nice fix. Since we always try to keep support for older devices, we could perhaps add a workaround for older APIs. Before API 29, we were provided with versions of method vibrate which were eventually deprecated (example: https://developer.android.com/reference/android/os/Vibrator#vibrate(long[],%20int)).
In this post, somebody has emulated double and heavy click for older devices: https://stackoverflow.com/a/60233086
With a bit of tweaking we might be able to add click effect too (should be simplier than the two mentioned above).

@asharghi
Copy link
Contributor Author

asharghi commented Jun 9, 2023

Thanks for the feedback. With this PR, I’m not removing support for old devices since it’s not supported in the first place. Just want to prevent a crash with this PR. Hope it will do for now.

@NathanWalker NathanWalker merged commit ad01b44 into NativeScript:main Jun 9, 2023
@NathanWalker
Copy link
Contributor

Available in 3.0.2 now.

@asharghi asharghi deleted the patch-2 branch June 9, 2023 16:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants