Put a copy of the source package com.google.zxing.client. * into your project. You can start the zxing scan operation as follows:
Intent intent = new Intent(this, CaptureActivity.class); startActivityForResult(intent, 0);
In the same action that you called CaptureActivity, you can process the result when validation is completed using the following onActivityResult method:
protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (data != null) { String response = data.getAction(); if(Pattern.matches("[0-9]{1,13}", response)) { // response is a UPC code, fetch product meta data // using Google Products API, Best Buy Remix, etc. } else { // QR codes - phone #, url, location, email, etc. Intent intent = new Intent(Intent.ACTION_VIEW); intent.setData(Uri.parse(response)); startActivity(intent); } } }
Hope this helps.
jengelsma
source share