I have scanner fragment, which realized with CameraX and Barcode Scanning. When barcode is found I want do some vibration for user. But device not vibrate. I use this code
if (Build.VERSION.SDK_INT >= 26) {
(requireContext().getSystemService(VIBRATOR_SERVICE) as? Vibrator)
?.vibrate(
VibrationEffect.createOneShot(200, VibrationEffect.DEFAULT_AMPLITUDE)
)
} else {
(requireContext().getSystemService(VIBRATOR_SERVICE) as? Vibrator)
?.vibrate(200)
}
and this permission
<uses-permission android:name="android.permission.VIBRATE" />
I add vibration code to some click listener, no reaction when camera work. But if disabling camera initialization, device vibrate on click. Are there any restrictions for vibration?