Skip to content

Instantly share code, notes, and snippets.

@Barneybook
Forked from billdawson/qrscan.js
Created July 11, 2012 08:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Barneybook/3088873 to your computer and use it in GitHub Desktop.
Save Barneybook/3088873 to your computer and use it in GitHub Desktop.
QR Code Scan Example from Marshall's "Developing Native Android Apps with Titanium" Webinar
qrScanButton.addEventListener("click", function(e) {
var intent = Ti.Android.createIntent({
action: "com.google.zxing.client.android.SCAN"
});
intent.putExtra("SCAN_MODE", "QR_SCAN_MODE");
var activity = Ti.Android.currentActivity;
activity.startActivityForResult(intent, function(e) {
if (e.resultCode == Ti.Android.RESULT_OK) {
var contents = e.intent.getStringExtra("SCAN_RESULT");
var format = e.intent.getStringExtra("SCAN_RESULT_FORMAT");
Ti.UI.createNotification({
message: "Contents: " + contents + ", Format: " + format
}).show();
} else if (e.resultCode == Ti.Android.RESULT_CANCELED) {
Ti.UI.createNotification({
message: "Scan canceled!"
}).show();
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment