- 二维码zxing使用-集成zxing
- 二维码zxing使用-生成二维码
public void click(View view) { String str = et.getText().toString().trim(); if (TextUtils.isEmpty(str)) { Toast.makeText(this, "数据不能为空!!!", Toast.LENGTH_SHORT).show(); } else { try { Bitmap bitmap = BitmapUtils.create2DCode(str); iv.setImageBitmap(bitmap); } catch (WriterException e) { e.printStackTrace(); } } }
- 二维码zxing使用-扫码
public void click(View view) { Intent intent = new Intent(this, CaptureActivity.class); startActivityForResult(intent,rc); } @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode==rc){ String qrcode_result = data.getStringExtra("qrcode_result"); tv.setText(qrcode_result); if (qrcode_result.contains("http")){ /* <intent-filter> <action android:name="android.intent.action.VIEW" /> <category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.BROWSABLE" /> <data android:scheme="http" /> <data android:scheme="https" /> <data android:scheme="about" /> <data android:scheme="javascript" /> </intent-filter>*/ Intent intent = new Intent(); intent.setAction("android.intent.action.VIEW"); intent.addCategory("android.intent.category.DEFAULT"); intent.addCategory("android.intent.category.BROWSABLE"); intent.setData(Uri.parse("http:"+qrcode_result)); startActivity(intent); } } }
- 二维码zxing使用-处理扫码结果
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode==rc){ String qrcode_result = data.getStringExtra("qrcode_result"); tv.setText(qrcode_result); if (qrcode_result.contains("http")){ /* <intent-filter> <action android:name="android.intent.action.VIEW" /> <category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.BROWSABLE" /> <data android:scheme="http" /> <data android:scheme="https" /> <data android:scheme="about" /> <data android:scheme="javascript" /> </intent-filter>*/ Intent intent = new Intent(); intent.setAction("android.intent.action.VIEW"); intent.addCategory("android.intent.category.DEFAULT"); intent.addCategory("android.intent.category.BROWSABLE"); intent.setData(Uri.parse("http:"+qrcode_result)); startActivity(intent); } } }