Pyjnius Vibrator Example
Pawek edited this page Mar 12, 2020
·
3 revisions
- author: brousch
- kivy: >= 1.4
Python code for triggering a vibration on Android.
from jnius import autoclass
def do_vibrate(self, pattern):
PythonActivity = autoclass('org.kivy.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
There was a mistyped ' in print statement. ~Pawek