Logo

DataWeave

  • Archive
  • RSS

How we created Lowprice Android app - Part 2

[Guest post from Pranay Airan who’s an early adopter of DataWeave. Pranay is enthusiastic about app development. Below he shares his experiences of developing LowPrice, an Android app powered by DataWeave’s pricing API. This is the second and final part of his post.]

In part-1 of this post, I discussed about the BookSearch API provided by DataWeave. In this part, I will discuss the Scan & Search functionality and integrating these to complete our Android App.

SCAN:

The ISBN number of a book can be obtained by scanning the bar code directly using the camera on your android phone. LowPrice, by itself is not bundled with this capability. To achieve this functionality, we use a native concept on Android called Intents. Intents allows us to delegate required functionality to already existing apps, thus eliminating the need to reinvent the wheel. Google provides an open source barcode scanner app ZXING. We will now use Intents to delegate the barcode scanning functionality to ZXING.

 Intent intent = new Intent("com.google.zxing.client.android.SCAN");
intent.putExtra("SCAN_MODE", "QR_CODE_MODE");
startActivityForResult(intent, 0);

We create an intent to use the barcode scanning functionality of ZXING in the first line. Then we define the mode in which the scanning has to be started. Different modes for different uses are defined on the ZXING website. Once the intent is created, we now start the intent and listen for results from the barcode scanner. Starting an intent will launch the corresponding application.

To get data from the barcode scanner:

 public void onActivityResult(int requestCode, int resultCode, Intent intent) { 
if (requestCode == 0) {
if (resultCode == RESULT_OK) {
String contents = intent.getStringExtra("SCAN_RESULT");
String format = intent.getStringExtra("SCAN_RESULT_FORMAT");

Once ZXING detects a valid barcode, the function defined above will be invoked, which will read the barcode and convert it to string for compatibility with the BookSearch API. This simple piece of code will provide our app with all the functionalities of a barcode scanner.

Integrating both

Now that we have the ISBN  number from the Scan module, we can use the searchByIsbn method from DataWeave’s BookSearch API to fetch the price of the book across various vendors in India.This is described in detail in part-1 of this post.

This is the story of LowPrice for now. Creating an Android App made easy. Do expect more in the future.

I can be reached at pranay.airan@iiitb.net . Feel free to provide your feedback at contact@dataweave.in .

Download lowprice android app now https://play.google.com/store/apps/details?id=com.binarybricks.lowprice 

  • 5 months ago
  • Comments
  • Permalink
  • Share
    Tweet

Recent comments

Blog comments powered by Disqus
← Previous • Next →

About

DataWeave provides data to businesses by creating curated datasets on the Web and letting them access this data through data APIs.

Twitter

loading tweets…

I Dig These Posts

See more →
  • RSS
  • Random
  • Archive
  • Mobile

DataWeave Software Private Limited. Effector Theme by Carlo Franco.

Powered by Tumblr