Time

58 views
Skip to first unread message

EdasCZ

unread,
Sep 12, 2012, 6:11:14 AM9/12/12
to app-reactor...@googlegroups.com
I would like to start activity in exactly hour. For example enable WIFI after 5 o'clock... is it possible?
Thank you for response :)

Petr Nalevka

unread,
Sep 12, 2012, 6:27:01 AM9/12/12
to app-reactor...@googlegroups.com
Hello,

this should be perfectly feasible. Please try to use the wake() function http://appreactorandroid.blogspot.cz/p/reference.html#wake. This should wake your phone after a timeout and then you can enable wifi. In case you would like a Wifi at 5 o'clock :) for example you would use the cron() function.

Thank you very much.

Best regards,

Petr




On Wed, Sep 12, 2012 at 12:11 PM, EdasCZ <e.vese...@gmail.com> wrote:
I would like to start activity in exactly hour. For example enable WIFI after 5 o'clock... is it possible?
Thank you for response :)



--
Best regards,

Petr

Alan Sperandio

unread,
Apr 22, 2015, 6:10:53 AM4/22/15
to app-reactor...@googlegroups.com, pe...@nalevka.com
Hello!  I don't understand clearly how to use function time() in the case descripted above.
Personnaly i can't use the output of the function time() as a number. So I can't do a while() properly because if I pass in the condition the value of time() come out a error like this: "TypeMismatchException: 'dictionary' instead of 'number'."
So I need to convert the 'dictionary' output from time() to a number.

I post the script I want to create (with "??" where I don't understand):

trigger = "true";

while(trigger){
 
  //get the time
  r = time(??);
 
 
  if (r<10:00) {
     //if earlier of time target, wait 2 minutes
     sleep(12000);
  }
  else {
      //else is time to turn off Airplaine mode
      con = hasConnectivity();
      if (!con) {
            enableAirplane(false);
            alert("Connectivity Enabled");
            trigger = "false";

Alan Sperandio

unread,
Apr 22, 2015, 7:06:09 AM4/22/15
to app-reactor...@googlegroups.com
Ok now i find a right way to use the functions, I used cron() instead of time().
The working script is following:

while(true){
  //every day at 8:30am
  cron("0 30 8 * * ?",true);


  con = hasConnectivity();

  if (!con) {
      enableAirplane(false);
      alert("Airplane Mode off",false);
  }
}

Reply all
Reply to author
Forward
0 new messages