How To

Following Microsoft’s Recipes for Android Self-Programming

Microsoft is involved in a project geared toward self-programming and extending the functionality of the Android smartphone environment. That’s surprising, because Microsoft has got its own phone OS that competes.

However, on{X} (pronounced “on-ex”) in beta is bringing some unique JavaScript APIs tothe table that let you program your phone remotely.

How It Works

Javascript rules you create on the on{X} website are pushed to the phone. When theyare triggered using phone functions like GPS, they run actions. Actions can include SMStext messaging, opening an app, and so on. Triggers can include GPS location, news andweather feeds.

on{X} uses the term “recipes” for its rules. Example recipes include turning the phone’sBluetooth radio on when you arrive or leave a location; showing you the weather forecasteveryday at a specific time if the anticipated temperature is below a set level; and textingsomeone when you arrive or leave a specific location.

Recipes can be turned on and off at the phone.

If you’ve used the common website programming language JavaScript before, you’ll findthe whole process easy and can jump in. If you haven’t, here follows a brief “how to”explaining the editing of a simple example recipe and getting it to work.

Step 1: Getting Started

Browse to the on{X} website using a PC and click on the “Get Started” link.Choose “Download the on{X} app” and follow the hyperlink that takes you to theGoogle Play store.

Install the app onto your Android smartphone. Log in to the phone app with a Facebookaccount.

Browse back to the on{X} website on the PC, and log in with Facebook. Choose yourFacebook privacy settings here.

Select the “Recipes” tab on the PC website, and scroll down to the recipe sample: “WhenI arrive home, remind me to buy milk.” This code snippet will form the basis for our testrecipe and will use your location as defined by a variable to create a geo-region for atrigger. On entering the region, a notification will be initiated on the phone.

Click “Code” and the base source code will be displayed. Then click “Create new rulefrom source code.”

Step 2: Your Location

Browse to Worldatlas or similar within a new browser tab on the PC (see below) and choose the “Quickly find the latitude and longitude” link.

Enter your current street address location, and the latitude and longitudinal coordinates ofyour location will be displayed in decimal position format — the format used by on{X}.

You can also use a free GPS tool apps like Mictale’s GPS Essentials or Chartcross’s GPSTest to pull this data from your phone. Verify it’s displaying in decimal format and notdegrees by checking that the syntax is two digits followed by a decimal point followed bya series of digits.

Step 3: Your Code

Replace the existing latitude and longitude “initializing variables” in the on{X} sourcecode with your data. Include six digits after the decimal point — dropping any further digitsgenerated by your source. The minus sign represents “W” in decimal notation.

Replace the text “buy milk” with something more interesting, like “open beer.”

Reduce the geographic region’s size by changing the radius (in yards) within the “georegion” to “500.” This will mean you won’t have so far to go when testing.

Change the rule name to “When I arrive home remind me to open beer,” or whatever isappropriate, depending on the changes to the reminder verb and noun in the initializingvariable.

Click “Save and Send to Phone.” Then check the phone and your rule will be listed in theon{X} app on the phone.

Step 4: Testing

Test by leaving the perimeter you set earlier, and then returning.

Bear in mind GPS inaccuracies, and that the app utilizes sensor readings that take intoaccount your motion. More motion equals more sampling. Verify the GPS stays alivewhile outside your perimeter.

Tips: Full documentation, including objects, further samples and a user forum are at the website.

Want to Ask a Tech Question?

Is there a piece of tech you’d like to know how to operate properly? Is there a gadget that’s got you confounded? Please send your tech questions to me, and I’ll try to answer as many as possible in this column.

And use the Talkback feature below to add your comments!

Patrick Nelson has been a professional writer since 1992. He was editor and publisher of the music industry trade publication Producer Report and has written for a number of technology blogs. Nelson studied design at Hornsey Art School and wrote the cult-classic novel Sprawlism. His introduction to technology was as a nomadic talent scout in the eighties, where regular scrabbling around under hotel room beds was necessary to connect modems with alligator clips to hotel telephone wiring to get a fax out. He tasted down and dirty technology, and never looked back.

Leave a Comment

Please sign in to post or reply to a comment. New users create a free account.

Technewsworld Channels