I want to create a Google glass application in which i want to scan a QR code.
I went through this post but i couldn't get clear idea.
Can anyone please direct me how to scan a QR code and get its content in Google Glass.
Thanks
I want to create a Google glass application in which i want to scan a QR code.
I went through this post but i couldn't get clear idea.
Can anyone please direct me how to scan a QR code and get its content in Google Glass.
Thanks
Instructions are using Android Development version of Eclipse.
Glass is running a version of Android 4.0.3. You can slideload an app using an .apk
This project, Barcode Eye, ports the ZXing project to Google Glass https://github.com/BarcodeEye/BarcodeEye
After you clone the repo, add GDK, and build you can port it to your device.
It has hooks for Amazon, Ebay and Google in it already
Here is a good solution I found later on.
Here is how to start a basic glassware that starts the QR scanner, returns a result, and sets it as the view card.
Basic program, just the section
protected void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
Intent intent = new Intent("com.google.zxing.client.android.SCAN");
intent.setPackage("com.google.zxing.client.android");
intent.putExtra("SCAN_MODE",ONE_D_MODE,QR_CODE_MODE,PRODUCT_MODE,DATA_MATRIX_MODE");
startActivityForResult(intent, UPC_CODE_REQUEST);
Card card1 = new Card(this);
card1.setText("Spoken Words!");
card1.setFootnote("my app");
View card1View = card1.toView();
setContentView(card1View);
setDisplayCard(card1);
}
//when a QR code is read, it will send a result code
protected void onActivityResult(int requestCode, int resultCode,
Intent data) {
if (requestCode == UPC_CODE_REQUEST && resultCode == RESULT_OK){
String contents = data.getStringExtra("SCAN_RESULT");
Card card1 = new Card(this);
card1.setText(contents);
card1.setFootnote("zxing");
View card1View = card1.toView();
setContentView(card1View);
setDisplayCard(card1);
}
super.onActivityResult(requestCode, resultCode, data);
}
Intent objIntent = new Intent("com.google.zxing.client.android.SCAN");
objIntent.putExtra("SCAN_MODE", "QR_CODE_MODE");
startActivityForResult(objIntent, 0);
Check if this will work for you, it is working on ADT (Mobile)
package com.metaio.example_internal;
import android.os.Bundle;
import android.widget.TextView;
import com.metaio.sdk.ARViewActivity;
import com.metaio.sdk.MetaioDebug;
import com.metaio.sdk.jni.IGeometry;
import com.metaio.sdk.jni.IMetaioSDKCallback;
import com.metaio.sdk.jni.TrackingValues;
import com.metaio.sdk.jni.TrackingValuesVector;
public class QRCodeReader extends ARViewActivity
{
/**
* Text view that will display bar code data
*/
private TextView mText;
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
mText = new TextView(this);
mGUIView = mText;
}
@Override
protected int getGUILayout()
{
return 0;
}
/**
* Display a text on screen
* @param data String to be displayed
*/
private void displayText(final String data)
{
runOnUiThread(new Runnable()
{
@Override
public void run() {
mText.setText(data);
}
});
}
@Override
protected IMetaioSDKCallback getMetaioSDKCallbackHandler()
{
return new MetaioSDKCallbackHandler();
}
@Override
protected void loadContents()
{
// set QR code reading configuration
final boolean result = metaioSDK.setTrackingConfiguration("QRCODE");
MetaioDebug.log("Tracking data loaded: " + result);
}
@Override
protected void onGeometryTouched(final IGeometry geometry)
{
}
final class MetaioSDKCallbackHandler extends IMetaioSDKCallback
{
@Override
public void onTrackingEvent(TrackingValuesVector trackingValues)
{
if (trackingValues.size() > 0)
{
final TrackingValues v = trackingValues.get(0);
if (v.isTrackingState())
{
final String[] tokens = v.getAdditionalValues().split("::");
if (tokens.length > 1)
{
displayText("QR Code detected: "+tokens[1]);
}
}
}
}
}
}
Have recently launched a modified version of zxing library known as BarcodeFragLib, The library is compatible for any form factor and have tested it my self to work on Google Glass :) You can find the implementation sample and code is available at https://code.google.com/p/barcodefraglibv2/wiki/HowTo
Hope this helps :)
which libraries have to be included to the own glass app if I want to run the scanner? What I did so far was to get this here: https://github.com/BarcodeEye/BarcodeEye The project works fine on glass :)
Greetings
© 2022 - 2024 — McMap. All rights reserved.