Page 1 of 1

mobileVibrate Command

Posted: Fri Jun 07, 2013 8:04 pm
by archer2009BUSknbj
I want to write n App for Android that makes my phone Vibrate

I've found the command mobileVibrate

And seen the example in the dictionary that says mobileVibrate 7 will get your phone to vibrate 7 times

But what I want to do is get my phone to Vibrate for different lengths of time - sort of like Morse Code style - long and short vibrations

like maybe vibrate 1 seconds, then 2 seconds, etc - is this possible?


Also I get an error when I run the code below (using Windows 7):


on mouseUp
beep 7
mobileVibrate 7
end mouseUp


button "Button_Beep": execution error at line 3 (Handler: can't find handler) near "mobileVibrate", char 1

What is causing the above error?
is it because I'm trying to run a command for mobile phone in Windows or something else?

Re: mobileVibrate Command

Posted: Sat Jun 08, 2013 11:05 am
by Mark
Hi,

No, I don't think that's possible. The API that manages the vibration has only one command to make the phone vibrate. In Objective-C, you need to use arepeat loop if you want to make the phone vibrate for a long time. That's what LiveCode does: mobileVibrate 7 makes the repeat loop run 7 times. There doesn't seem to be another way.

Kind regards,

Mark

Re: mobileVibrate Command

Posted: Sat Jun 08, 2013 11:32 am
by Klaus
Hi guys,

according to the doc, thiks is possible on iOS and Android!

The ERROR is caused from the fact that the IDE does NOT recognize MOBILE ocmmands and will throw an error when it encounters one!
I think this is completely stupid, but that's the way it is...

You will always need to use IF... THEN... with native mobile commands:

Code: Select all

on mouseUp
  beep 7

  ## ONLY execute this on the mobile simulator or real device:
  if the environment = "mobile" THEN
     mobileVibrate 7
  end if
end mouseUp
Best

Klaus

Re: mobileVibrate Command

Posted: Sat Jun 08, 2013 11:54 am
by Mark
Hi Klaus,

On iOS, the command mobileVibrate N is possible (where N is an integer). However, when you execute this command, you will get N times a brief vibration. It is impossible to get long and short vibrations in the sense of morse code.

Kind regards,

Mark

Re: mobileVibrate Command

Posted: Sat Jun 08, 2013 12:10 pm
by Klaus
Hi Mark,

oh, yes, sorry, my fault, need to read more carefully!


Best

Klaus

Re: mobileVibrate Command

Posted: Sat Jun 08, 2013 12:27 pm
by Mark
That's ok, Klaus. I guess my answer wasn't complete.

Mark