答案 0 :(得分:4)
说明正在使用Eclipse的Android开发版。
Glass正在运行Android 4.0.3版本。您可以使用.apk
来滑动应用此项目Barcode Eye将ZXing项目移植到Google Glass https://github.com/BarcodeEye/BarcodeEye
克隆回购后,添加GDK,然后构建,您可以将其移植到您的设备。
已经有亚马逊,Ebay和谷歌的钩子
答案 1 :(得分:3)
这是我后来发现的一个很好的解决方案。
以下是如何启动启动QR扫描仪的基本玻璃器皿,返回结果并将其设置为视图卡。
基本程序,只是部分
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);
}
答案 2 :(得分:2)
Intent objIntent = new Intent("com.google.zxing.client.android.SCAN");
objIntent.putExtra("SCAN_MODE", "QR_CODE_MODE");
startActivityForResult(objIntent, 0);
检查这是否适合您,它正在使用ADT(移动)
答案 3 :(得分:2)
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]);
}
}
}
}
}
}
答案 4 :(得分:1)
最近推出了一个名为BarcodeFragLib的zxing库的修改版本, 该库兼容任何外形尺寸,并在Google Glass上自行测试:) You can find the implementation sample and code is available at https://code.google.com/p/barcodefraglibv2/wiki/HowTo
希望这会有所帮助:)
答案 5 :(得分:0)
问候