Sub Class_Globals
Private Root As B4XView
Private xui As XUI
Private SelectionFeedbackGenerator As NativeObject
Private NotificationFeedbackGenerator As NativeObject
End Sub
Public Sub Initialize
End Sub
'This event will be called once, before the page becomes visible.
Private Sub B4XPage_Created (Root1 As B4XView)
Root = Root1
Root.LoadLayout("MainPage")
SelectionFeedbackGenerator.Initialize("UISelectionFeedbackGenerator")
If SelectionFeedbackGenerator.IsInitialized Then
SelectionFeedbackGenerator = SelectionFeedbackGenerator.RunMethod("new", Null)
End If
NotificationFeedbackGenerator.Initialize("UINotificationFeedbackGenerator")
If NotificationFeedbackGenerator.IsInitialized Then
NotificationFeedbackGenerator = NotificationFeedbackGenerator.RunMethod("new", Null)
End If
End Sub
Private Sub Button1_Click
PerformNotificationFeedback(2)
End Sub
Private Sub PerformImpactFeedback (view As B4XView)
XUIViewsUtils.PerformHapticFeedback(view) 'the view is only used in B4A
End Sub
Private Sub PerformSelectionFeedback
If SelectionFeedbackGenerator.IsInitialized Then
SelectionFeedbackGenerator.RunMethod("selectionChanged", Null)
End If
End Sub
'0 - Success, 1 - Warning, 2 - Error
Private Sub PerformNotificationFeedback(FeedbackType As Int)
If NotificationFeedbackGenerator.IsInitialized Then
NotificationFeedbackGenerator.RunMethod("notificationOccurred:", Array(FeedbackType))
End If
End Sub