After my last video about using a barcode scanner to add and search books in your library, I was feeling pretty happy. Bar code scanners are pretty cheap–mine cost about $65. But then Google released the Android Scripting Environment (ASE) and it turns out that you don’t even need a bar code scanner. Instead, you can use an Android phone such as the G1.
Just as a proof-of-concept, here’s a barcode scanner written in six lines of Python code:
droid = android.Android()
code = droid.scanBarcode()
isbn = int(code[‘result’][‘SCAN_RESULT’])
url = “http://books.google.com?q=%d” % isbn
Thanks to fellow Googler Vijayakrishna Griddaluru for sending me this sample code. Visiting the resulting url offers the option to add that book to your library:
Pretty easy, huh? You can read all about the new scripting environment. Not only can you scan bar codes, you can use text-to-speech, make phone calls, send text messages, read sensor data, and find your location–all from easy scripts. One person wrote a script to go into silent mode when the phone is placed screen-down on the table. It took less than 20 lines of code, and that’s including comments!
The Android Scripting Environment should make fun projects even easier. Brad Fitzpatrick wrote about using his Android phone to open his garage door automatically when his motorcycle gets close to home. Now those sorts of projects are even easier to write. 🙂