问题的意图,通过使用Zxing如果安装了谷歌眼镜 [英] Issue in using Zxing via intent if google goggles is installed
问题描述
我使用下面的code调用由诚律师code扫描仪应用
I am using following code to invoke Barcode scanner apps from Zing
public Button.OnClickListener mScan = new Button.OnClickListener() {
public void onClick(View v) {
Intent intent = new Intent("com.google.zxing.client.android.SCAN");
intent.putExtra("SCAN_MODE", "QR_CODE_MODE");
startActivityForResult(intent, 0);
}
};
public void onActivityResult(int requestCode, int resultCode, Intent intent) {
if (requestCode == 0) {
if (resultCode == RESULT_OK) {
String contents = intent.getStringExtra("SCAN_RESULT");
String format = intent.getStringExtra("SCAN_RESULT_FORMAT");
// Handle successful scan
} else if (resultCode == RESULT_CANCELED) {
// Handle cancel
}
}
}
现在的问题是,如果律师code扫描仪的应用程序未安装和用户有一个像谷歌护目镜任何其它扫描应用程序,我没有得到期望的结果back.This打破了我的申请。
The problem is if Barcode scanner app is not installed and user has any other scanning app like google goggles i dont get desired result back.This breaks my application.
有没有什么办法,我可以prevent这??
Is there any way in which i can prevent this ??
推荐答案
是的。叫 Intent.setPackage()
与价值com.google.zxing.client.android。这将迫使它只能接受吧code扫描仪的响应。
Yes. call Intent.setPackage()
with value "com.google.zxing.client.android". This will force it to only accept a response from Barcode Scanner.
但是请注意,这将使其无法用于其他应用响应,像酒吧code扫描仪+。
Note however that this will make it impossible for other apps to respond, like Barcode Scanner+.
这篇关于问题的意图,通过使用Zxing如果安装了谷歌眼镜的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!