Pyjnius Vibrator Example

Ben Rousch edited this page Oct 15, 2013 · 1 revision

Summary

  • author: brousch
  • kivy: >= 1.4

Python code for triggering a vibration on Android.

Files

main.py

from jnius import autoclass

def do_vibrate(self, pattern):
    PythonActivity = autoclass('org.renpy.android.PythonActivity')
    Context = autoclass('android.content.Context')
    activity = PythonActivity.mActivity
    vibrator = activity.getSystemService(Context.VIBRATOR_SERVICE)
    if vibrator.hasVibrator():
        vibrator.vibrate(pattern)
    else:
        print("Your device does not have a vibration motor."')

##Comments

Section for user comments

Clone this wiki locally
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.