Pages

Labels

Sample (14) Intent (5) Media (5) Funny (3) HTTP (3) Location (3) Sleep as Android (3) Alarm (2) Recording (2) Regexp (2) WiFi (2) Array (1) Battery (1) Browser (1) Calculator (1) Contacts (1) Content Provider (1) Cron (1) Dialog (1) Dictionary (1) Export (1) Function (1) GUI (1) Game (1) Loop (1) Random (1) SD Card (1) Social (1) Temperature (1) Text to Speech (1) Weather (1)

Search Scripts

Loading...

2013-05-19

Weather forecast by Taha

// timeout
r = waitForConnectivity(0);

beep(2000);

response = httpGet("http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20weather.forecast%20where%20woeid%3D1540935&format=json&callback=cbfunc");

speak("Attention : flash météo","french");

temp = find('"temp":"([0-9]+)"', response[1]);
tempC = round((number(temp[0])-32)*0.555);
humidity = find('"humidity":"([0-9]+)"', response[1]);

speed = find('"speed":"([0-9]+)"', response[1]);
speedKph = round(number(speed[0])/1.6);

windDirection = find('"direction":"([0-9]+)"', response[1]);

windL = "";
if(number(windDirection) > 285){
windL = "Nord ";
}
if(number(windDirection) < 75) {
windL = "Nord ";
} 
if(number(windDirection) < 255){
if(number(windDirection) > 105) {
windL = "Sud ";
}}
if(number(windDirection) > 45 ){
if(number(windDirection) < 135) {
windL = windL ~ "Est ";
}}
if(number(windDirection) < 325){
if(number(windDirection) > 225 ) {
windL = windL ~ "Ouest ";
}}

visibility = find('"visibility":"([0-9]+.[0-9]+)"', response[1]); 
visibilityKm = round( number(visibility[0])*1.6);
speak("La température à Tanger est "~tempC~" °C","french");
speak("L'humidité est de "~humidity[0]~"%","french");
speak("La vitesse du vent  est "~ speedKph~" Km/h en direction "~windL,"french");
speak("La visibilité est de "~ visibilityKm~" Km","french");

beep(2000);

2013-02-26

Turn wifi on when coming home (by Jaromir)

// Turn wifi on when coming home 

loc = location(); 
log("Current location lat: " ~ loc["lat"] ~ " lon: " ~ loc["lon"]); 

while(true) { 

  //if airplane mode ON, don't turn wifi ON 
  if(setting("airplane_mode_on") == 0){ 

    // put your home location here 
    iAmHome = near(50.00, 14.00, 1000); 

    if (iAmHome) { 
      log("At home"); 
      enableWifi(true); 
    } 
  } 

  // wait 2 minutes till next check 
  sleep(120000); 
}

2012-12-28

Drop the bomb (by Jeremy)

r = rand(5, 60);

while (r > 0)
{
beep();
r = r - 1;
sleep(1000);
}

noise = play("/sdcard/download/bomb.mp3", "");

2012-10-10

View image

startIntent("android.intent.action.VIEW", "file:///sdcard/urbandroid.png", "image/png");

2012-06-28

Sample: Address from Facebook


here = location(false, 2);
result = httpGet("http://maps.googleapis.com/maps/api/geocode/json?latlng="~here["lat"]~","~here["lon"]~"&sensor=true");

log(""~result[1]);

place = find("formatted_address. : (.*)", result[1]);

post("Currently I'm at "  ~ place[0], "facebook");
post("Currently I'm at " ~  place[0], "twitter");

2012-03-07

Wake with Radio


// play FM radio when alarm starts, Sleep as Android and FMAlarm needs to be installed
while(true) {  
  waitForIntent("com.urbandroid.sleep.alarmclock.ALARM_ALERT_START");
  
  con = hasConnectivity();

  if (!con) {
    enableAirplane(false);
  }

  // start the FMAlarm
  sendIntent("com.rejh.fmalarm2.intents.ALARM");

}

2012-02-20

Sputnik

// Spitnik demonstrates the use of alarm wake-up - activates your phone even from stand-by
// Spitnik beeps every 5 seconds, beeping won't stop even when pressing the power button

while(true) {

    // this is standard cron pattern (see Quartz)
    cron("0/5 * * * * ?");

    // This is equivalent to the cron call above
    // wake(5000);

    // will be called even from stand-by
    beep();

}