Android Question Vibrate effect with unlimited duration

Erel

B4X founder
Staff member
Licensed User
Longtime User
Here:
B4X:
Sub Activity_Create(FirstTime As Boolean)
   Dim v As PhoneVibrate
   v.Vibrate(10000000)
End Sub

Sub Activity_Click
   Dim v As JavaObject = GetContext
   v = v.RunMethodJO("getSystemService", Array ("vibrator")).RunMethod("cancel", Null)
End Sub

Sub GetContext As JavaObject
  Return GetBA.GetField("context")
End Sub

Sub GetBA As JavaObject
  Dim jo As JavaObject
  Dim cls As String = Me
  cls = cls.SubString("class ".Length)
  jo.InitializeStatic(cls)
  Return jo.GetFieldJO("processBA")
End Sub
 
Upvote 0

Johan Schoeman

Expert
Licensed User
Longtime User
The first part of the code below returns True - as expected. But there seems to be a problem with the syntax of the last line of code. Want vibrator to vibrate for 2000ms. Can someone please point me in the right direction?

B4X:
   Dim telMgr1 As JavaObject = GetContext.RunMethod("getSystemService", Array("vibrator"))
   Dim vib As Boolean = telMgr1.RunMethod("hasVibrator", Null)
   Log(vib)
 

   telMgr1.RunMethod("vibrate", Array As Object(2000))

This is the error:
java.lang.RuntimeException: Method: vibrate not matched.
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
Upvote 0
Top