Here's my Python script written using android-scripting:
import android, time
droid = android.Android()
interval = 1 # every 1 minute
while True:
# define your own vibrate pattern here
droid.vibrate(200)
time.sleep(0.3)
droid.vibrate(300)
time.sleep(60*interval)
It basically vibrates every minute (like a motivator). However, when the phone is locked with screen blanked out, I don't sense any vibration. Perhaps Android is freezing the script (and hence the while loop)? Note that I am indeed running this script as a service (long-tap and click 'Start as service').
Is there a way to make this script work all the time regardless of the phone suspend state?
Update 1: I do hear the vibration occasionally, not every minute .. but rather like every 5-10 minutes randomly.
Update 2: This problems occurs if I run the script normally (not as a service). Seems like "time.sleep" is not sleeping for the specified time.