Skip to content

Commit 9979113

Browse files
authored
fix(android): use decorView instead of detached View for performAndroidHaptics (#19)
Creating a new View(context) without attaching it to a window causes performHapticFeedback to silently do nothing. Use the activity's decorView which is always attached and has haptic feedback enabled.
1 parent 349385f commit 9979113

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

android/src/main/java/com/haptics/HybridHaptics.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,8 @@ class HybridHaptics: HybridHapticsSpec() {
132132
throw Error("Haptic feedback type '$type' not supported.")
133133
}
134134

135-
val view: View = View(NitroModules.applicationContext)
136-
view?.performHapticFeedback(feedbackType)
135+
val decorView = NitroModules.applicationContext?.currentActivity?.window?.decorView
136+
decorView?.performHapticFeedback(feedbackType)
137137
}
138138

139139
@DoNotStrip

0 commit comments

Comments
 (0)