jen*_*sma 10
将com.google.zxing.client.*源包的副本放入项目中.您可以像这样开始zxing扫描活动:
Intent intent = new Intent(this, CaptureActivity.class);
startActivityForResult(intent, 0);
Run Code Online (Sandbox Code Playgroud)
在您调用CaptureActivity的同一活动中,您可以使用以下onActivityResult方法在扫描完成时处理结果:
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (data != null) {
String response = data.getAction();
if(Pattern.matches("[0-9]{1,13}", response)) {
// response is a UPC code, fetch product meta data
// using Google Products API, Best Buy Remix, etc.
} else {
// QR codes - phone #, url, location, email, etc.
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse(response));
startActivity(intent);
}
}
}
Run Code Online (Sandbox Code Playgroud)
希望这可以帮助.
| 归档时间: |
|
| 查看次数: |
12186 次 |
| 最近记录: |