github.com/maning0303/…
- :生成二维码(带Logo)
- :二维码扫描
- :相册中选取图片识别
- :开启闪光灯
- allprojects {
- repositories {...maven {
- url "https://jitpack.io"
- }
- }
- }
- dependencies {
- compile 'com.github.maning0303:MNZXingCode:V1.1.0'
- }
- 1.跳转:
- Intent intent = new Intent(this, CaptureActivity.class);
- //是否显示相册按钮
- intent.putExtra(CaptureActivity.INTENT_KEY_PHOTO_FLAG, true);
- //识别声音
- intent.putExtra(CaptureActivity.INTENT_KEY_BEEP_FLAG, true);
- //识别震动
- intent.putExtra(CaptureActivity.INTENT_KEY_VIBRATE_FLAG, true);
- //扫码框的颜色
- intent.putExtra(CaptureActivity.INTENT_KEY_SCSNCOLOR, "#FFFF00");
- //扫码框上面的提示文案
- intent.putExtra(CaptureActivity.INTENT_KEY_HINTTEXT, "请将二维码放入框中....");
- startActivityForResult(intent, 1000);
- 2.获取结果:
- @Override
- protected
- void
- onActivityResult
- (int requestCode, int resultCode, Intent data)
- {
- super.onActivityResult(requestCode, resultCode, data);
- if (requestCode == 1000) {
- if (data == null) {
- return;
- }
- switch (resultCode) {
- case CaptureActivity.RESULT_SUCCESS:
- String resultSuccess = data.getStringExtra(CaptureActivity.INTENT_KEY_RESULT_SUCCESS);
- showToast(resultSuccess);
- textView.setText(resultSuccess);
- break;
- case CaptureActivity.RESULT_FAIL:
- String resultError = data.getStringExtra(CaptureActivity.INTENT_KEY_RESULT_ERROR);
- showToast(resultError);
- break;
- case CaptureActivity.RESULT_CANCLE:
- showToast("取消扫码");
- break;
- }
- }
- }
- 3:生成二维码:
- Bitmap qrImage = ZXingUtils.createQRImage("xxxxxx");
- Bitmap qrImage = ZXingUtils.createQRCodeWithLogo("xxxxxx", logoBitmap);
zxing
BGAQRCode-Android
感谢所有开源的人
来源: https://juejin.im/post/5a057cd751882575d1447322