Basic4Android 振动模式

发布于 2024-12-10 04:06:57 字数 336 浏览 0 评论 0原文

我正在尝试创建一个具有不同振动模式的应用程序。

我已经看到 PhoneVibrate 类只有一个 Vibrate(TimeMs as Long) 函数。 我还看到还有另一个支持模式的java函数 (请参见此处:http://mobile.tutsplus.com/tutorials/android/android- vibrator/ )

可以在 Basic4Android 上使用吗?我该如何解决这个问题? 问候,

尼古拉

I'm trying to create an application that have different vibration patterns.

I've seen that the PhoneVibrate class has only a Vibrate(TimeMs as Long) function.
I've also seen that there also is another java function that supports patterns
(see here: http://mobile.tutsplus.com/tutorials/android/android-vibrator/ )

Is it possible to use it on Basic4Android? How do I solve this problem?
Regards,

Nicola

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

¢蛋碎的人ぎ生 2024-12-17 04:06:57

您可以使用此代码(需要电话库和反射库):

Sub Process_Globals
    Dim pv As PhoneVibrate 'Required to add the Vibrate permission
End Sub

Sub Globals

End Sub
Sub Activity_Create(FirstTime As Boolean)
    Vibrate(500, 300)
    ToastMessageShow("Click anywhere to stop vibrate.", True)
End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub
Sub Activity_Resume

End Sub

Sub Activity_Click
    CancelVibrate
End Sub

Sub Vibrate(On As Long, Off As Long)
    Dim r As Reflector
    r.Target = r.GetContext
    r.Target = r.RunMethod2("getSystemService", "vibrator", "java.lang.String")
    Dim pattern(2) As Long
    pattern(0) = On
    pattern(1) = Off
    r.RunMethod4("vibrate", Array As Object(pattern, 0), Array As String("[J", "java.lang.int"))
End Sub

Sub CancelVibrate
    Dim r As Reflector
    r.Target = r.GetContext
    r.Target = r.RunMethod2("getSystemService", "vibrator", "java.lang.String")
    r.RunMethod("cancel")
End Sub

You can use this code (requires Phone library and Reflection library):

Sub Process_Globals
    Dim pv As PhoneVibrate 'Required to add the Vibrate permission
End Sub

Sub Globals

End Sub
Sub Activity_Create(FirstTime As Boolean)
    Vibrate(500, 300)
    ToastMessageShow("Click anywhere to stop vibrate.", True)
End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub
Sub Activity_Resume

End Sub

Sub Activity_Click
    CancelVibrate
End Sub

Sub Vibrate(On As Long, Off As Long)
    Dim r As Reflector
    r.Target = r.GetContext
    r.Target = r.RunMethod2("getSystemService", "vibrator", "java.lang.String")
    Dim pattern(2) As Long
    pattern(0) = On
    pattern(1) = Off
    r.RunMethod4("vibrate", Array As Object(pattern, 0), Array As String("[J", "java.lang.int"))
End Sub

Sub CancelVibrate
    Dim r As Reflector
    r.Target = r.GetContext
    r.Target = r.RunMethod2("getSystemService", "vibrator", "java.lang.String")
    r.RunMethod("cancel")
End Sub
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文