Wednesday, December 17th, 2008

OilCan: Grease up your Android browser

Category: Java, JavaScript, Mobile

<p>

Jeffrey Sharkey has created OilCan a thin wrapper on top of the WebKit shipping on Android that allows you to install userscripts that allow you to access to Android “Intents”.

Intents are very nice abstractions that allow you to access large components and reuse them in different ways. Romain Guy has a nice post on them.

OilCan lets you customize any website by inserting JavaScript to change the website and help it reach into the Android world using intents.

OilCan inserts some powerful buttons into normal websites, and that power comes from Android intents. We didn’t write a barcode scanner or the radar app into OilCan, but using intents we can launch those apps with parameters. We can request the Barcode Scanner app to scan something and return the code to us, or launch the Radar app with a specific lat/lon.

Userscripts can do other cool stuff, like hide the navigation columns in Wikipedia to make it easier to view on small screens. This is a proof-of-concept for now, and will probably turn into a binary plugin for the default Browser in the future.

A nice piece from an example shows the intent call out:

javascript
< view plain text >
  1. function generate(item) {  
  2.     var helper = document.createElement('input');  
  3.     helper.type = 'button';  
  4.     helper.value = 'Scan barcode...';  
  5.     helper.addEventListener('click', function(event) {  
  6.         // use the intentHelper bridge to fire an intent to Barcode Scanner  
  7.         // it's available in Market, or from http://code.google.com/p/zxing/  
  8.         var result = window.intentHelper.startActivityForResult(JSON.stringify({  
  9.             action:'com.google.zxing.client.android.SCAN',  
  10.             category:['CATEGORY_DEFAULT']  
  11.         }));  
  12.  
  13.         // parse the result we get back, and read the barcode from the extras  
  14.         result = JSON.parse(result);  
  15.         item.value = result['extras']['SCAN_RESULT'];  
  16.     }, false);  
  17.     return helper;  
  18. }

Very cool!

Posted by Dion Almaer at 6:13 am
2 Comments

++++-
4 rating from 6 votes

2 Comments »

Comments feed TrackBack URI

A very nice idea, something I think Google missed a trick on. I could see many uses for this, for example if your hungry – fire up your browser to the Domino’s pizza website, and using Gears + This, it works out your location and gives you a button to dial your local store.

I’ll be keeping an eye on this.

Comment by digitalspaghetti — December 17, 2008

Oil can what?

Comment by Nosredna — December 17, 2008

Leave a comment

You must be logged in to post a comment.