我想让用户从他安装的应用程序中选择一个QR阅读器。这可以通过使用Intent.createChooser完成。使用QR阅读器拍摄照片时,应将QR码发送回我的应用程序。这是我迄今为止所尝试的:Intent.createChooser android二维码读取器
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("text/plain");
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
intent.putExtra("SCAN_MODE", "QR_CODE_MODE");
String title = (String) getResources().getText(R.string.chooser_title);
Intent chooser = Intent.createChooser(intent, title);
startActivityForResult(chooser, CUSTOM_REQUEST_QR_SCANNER);
扫描仪dons't无法正确启动,它只显示示例QR码。我有一种感觉intent.setType(“文本/平原”)可能是错的?什么类型的QR读码器?或者我该如何正确启动QR阅读器?
我也有当QR应用程序完成的ActivityResult:
@Override
public void onActivityResult(int requestCode, int resultCode, Intent intent) {
if (requestCode == CUSTOM_REQUEST_QR_SCANNER) {
Log.d(TAG, "QR activity complete");
//Successful scan
if (resultCode == RESULT_OK) {
我不明白'SEND''text/plain'是如何解决的,因为qr_code请求 – njzk2 2013-04-05 12:21:54
您是否使用任何类似于zxing或zbar的库? – Shiv 2013-04-05 12:33:04
你说得对,我应该使用zxing。 – rtc11 2013-04-05 12:41:35