将结果返回添加到BarcodeEye(ZXing玻璃端口),结果位置是什么



我正在尝试创建一个Glass应用程序,该应用程序扫描条形码并使用条形码中的信息打开特定文档。

在为Glass从源代码构建ZXing时遇到问题后,我转向了一个已经创建的名为BarcodeEye的端口:https://github.com/BarcodeEye/BarcodeEye

然而,BarcodeEye似乎没有内置支持将其用作意图。我在清单中添加了意向操作。这使我可以从我的应用程序调用BarcodeEye,但我在哪里调用setResult时遇到了问题,无法从BarcodeEye获得我的QR文本的结果。

有ZXing经验的人能帮助我理解为什么没有返回结果,以及将setResult代码放在哪里才能正确返回结果吗。

以下是我在应用程序中调用BarcodeEye的代码:

Intent intent = new Intent("com.github.barcodeeye.SCAN");
intent.putExtra("SCAN_MODE", "QR_CODE_MODE");//for Qr code, its "QR_CODE_MODE" instead of "PRODUCT_MODE"
intent.putExtra("SAVE_HISTORY", false);//this stops saving ur barcode in barcode scanner app's history
startActivityForResult(intent, 0);

这是我的成绩等级:

protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == 0) {
if (resultCode == RESULT_OK) {
String contents = data.getStringExtra("SCAN_RESULT"); //this is the result
Log.v("zxing",contents);
} else 
if (resultCode == RESULT_CANCELED) {
// Handle cancel
}
}
}

对于如何获得正确活动结果的任何帮助,我们将不胜感激。

编辑:

通过添加intent过滤器并将返回的数据放在CaptureActivity.java类中,我几乎可以让它正常工作。这对我来说很有效,因为我关心的QR只是文本,但我认为我目前的方法在某些情况下不起作用,因为它不会通过过滤器来检查它是什么类型的QR。

这是我的清单:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.chut.glass.xively"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="15"
android:targetSdkVersion="15" />
<uses-permission android:name="android.permission.INTERNET" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher_xi"
android:label="@string/app_name" >
<uses-library
android:name="com.google.android.glass"
android:required="true" />
<activity
android:name="com.chut.glass.xively.MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="com.google.android.glass.action.VOICE_TRIGGER" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
<meta-data
android:name="com.google.android.glass.VoiceTrigger"
android:resource="@xml/voice_trigger" />
</activity>
<service android:name="com.jessefarebro.mqtt.MqttService" android:exported="false" />
</application>

</manifest>

以下是我在CaputreActivity:中放置数据返回的地方

// Put up our own UI for how to handle the decoded contents.
private void handleDecodeInternally(Result rawResult, Bitmap barcode) {
Uri imageUri = null;
String imageName = IMAGE_PREFIX + System.currentTimeMillis() + ".png";
Log.v(TAG, "Saving image as: " + imageName);
try {
imageUri = mImageManager.saveImage(imageName, barcode);
} catch (IOException e) {
Log.e(TAG, "Failed to save image!", e);
}
ResultProcessor<?> processor = ResultProcessorFactory
.makeResultProcessor(this, rawResult, imageUri);
Intent data = new Intent();
data.putExtra("SCAN_RESULT", rawResult.toString());
if (getParent() == null) {
setResult(Activity.RESULT_OK, data);
Log.v(TAG,"parent null");
} else {
Log.v(TAG,"parent: " + getParent());
getParent().setResult(Activity.RESULT_OK, data);
}
Log.v(TAG,"about to finish");
finish();
Log.v(TAG,"post finish");
//startActivity(ResultsActivity.newIntent(this, processor.getCardResults(), imageUri));
}

我有一个BarcodeEye的分支,我在其中恢复/添加了ZXing的Intent功能:https://github.com/paulpv/BarcodeEye/tree/intent我已经在上游打开了一个Pull Request,看看BarcodeEye是否会接受它。我也在讨论是否有可能编写他们的条形码扫描仪(CaptureActivity)的官方GDK Glassware版本

最新更新