[Wish] Rumble queue

NeoTechni

Well-Known Member
Licensed User
Longtime User
The vibrate sub in java has a second version which lets you push a list of integers.

odd ones are the length in ms of the rumble, even ones are the the length of pauses between them

could you please add support for this?
 

NeoTechni

Well-Known Member
Licensed User
Longtime User
B4X:
Sub RumblePattern(Pattern() As Long)
    Dim r As Reflector
    r.Target = r.GetContext
    r.Target = r.RunMethod2("getSystemService", "vibrator", "java.lang.String")
    r.RunMethod4("vibrate", Array As Object(Pattern, 0), Array As String("[J", "java.lang.int"))
End Sub

RumblePattern( Array As Long(75,50,   75,50,    75,50,     75, 25,     75,25,     75,12,      75,12))
Doesn't seem to be working.
 
Last edited:

Roger Garstang

Well-Known Member
Licensed User
Longtime User
What is the error? No other code is shown, but when doing this you also need the Vibration Right which you get by using the Phone library and just dim a PhoneVibrate object that is never used. Mine worked fine yesterday after this. Remember to code a Cancel option too...this could get messy if not and it will continue vibrating after exit until you reboot or cancel it.
 

NeoTechni

Well-Known Member
Licensed User
Longtime User
You used the exact code I posted? Cause I got no rumble.
If not, can I have your code to use a rumble pattern?

And I am using the rumble object elsewhere so I have the permission
 

Roger Garstang

Well-Known Member
Licensed User
Longtime User
Yup, the attached code compiles and runs fine. Sounds kinda like some of the night bugs around here. Tap screen to stop it.

Might remove the FirstRun Check. I was worried about rotating the screen sending multiple rumble commands and making a mess, but it appears that is not the case and what you send replaces previous. FirstRun isn't very reliable on my device too and it appears to stay in memory long and doesn't vibrate on other attempts. Doesn't look like it is tied that much to the context either and you can still exit the app and leave it going and stop it by loading the app again and taping...might be interesting to test if it can be stopped from another app.
 

Attachments

  • Ready2Rumble.zip
    5.6 KB · Views: 217
Last edited:

NeoTechni

Well-Known Member
Licensed User
Longtime User
Your code worked. Mine didnt, even though they appear identical to me...

*shrugs* thank you.
 
Top