The G1 came out this week and I have been putting it through the paces. I really like the seamless transition between developing with the emulator and developing on the device. I think overall it is a very strong first device for Android, but I think that normal users may not recognize some of the more powerful features of the platform.
The Intent system allows for applications and activities to interact with each other, so that you can have applications using the features of other applications. I think this is a really interesting concept and think it could lead to a less application-centric view of phone operation towards a more feature-centric view. Instead of developing an entire application, developers can develop specific features that perform a very specific task. These features can be used by other applications to create new and interesting functionality.
I think the best example of this concept is Barcode Scanner. Barcode Scanner is the application specific manifestation of ZXing which I blogged about previously. Installing it lets you scan bar and QR Codes and lets you perform search actions or interact with the results(like an e-mail address or phone number). The two shopping applications CompareAnywhere and ShopSavvy use the ZXing library themselves for doing barcode scanning, but they include the ZXing library as part of their application bundle.
In my previous entry I mentioned that I would like to see specific Intents that let you use the encoding and decoding ability of ZXing from other applications and the ZXing team responded that the latest build had this exact functionality! Now all you have to do is install Barcode Scanner on your phone and your applications can take advantage of its features. Specifically, it provides Intents that allow your application to use the encoding and decoding functionality. The Intent mechanism makes it almost too simple to integrate this functionality into your application.
Encoding – “com.google.zxing.client.android.ENCODE”
To encode a string into a QR Code Simply create an Intent with the Decode action specified, two string extras specifying the Type and Data and call startActivity():
Intent intent = new Intent("com.google.zxing.client.android.ENCODE");
intent.addCategory(Intent.CATEGORY_DEFAULT);
intent.putExtra("ENCODE_TYPE", "TEXT_TYPE");
intent.putExtra("ENCODE_DATA","HELLO WORLD");
startActivity(intent);
The string values for the Intents and the extras values can be found in the Intents and Content classes in the ZXing source code.
Decoding – “com.google.zxing.client.android.SCAN”
Bringing up the decoding camera interface is just as easy as encoding with the added step of having it return the decoded value of the barcode to our main application.
Intent intent = new Intent("com.google.zxing.client.android.SCAN");
intent.addCategory(Intent.CATEGORY_DEFAULT);
startActivityForResult(tent,0);
The big difference here is that we are using startActivityForResult which will allow the scanning activity to return the results of the scan back to our app. In the Activity that launched the decode intent we can extract the results of the scan in the onActivityResult method by simply accessing the string extra “SCAN_RESULT”.
data.getStringExtra("SCAN_RESULT");

You can now use these features to do all kinds of interesting things. I am currently interested in transferring data between phones by encoding the data in a QR code and having the other phone retrieve it by simply pointing it at the other camera’s screen. You could also encode movie ticket information into a QR code and have it displayed on the phone so it can be scanned at the theater.
I hope this post showed you how useful Barcode Scanner can be for your application and it’s users. Now if someone could do something about the reviewers in the android app store…..