基于Zxing二次开发封装,可直接使用,封装了权限/相册等等
Step 1. Add the JitPack repository to your build file Add it in your root build.gradle at the end of repositories:
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
Step 2. Add the dependency
dependencies {
implementation 'com.github.wintonBy:EasyZxing:1.0'
}
##使用方法
public static void start(Activity context,int req)
public static void start(Activity context,int req,boolean needAlbum)
ScanActivity.start(ManiActivity.this,123);
@Override
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
super.onActivityResult(requestCode, resultCode, data);
switch (requestCode){
case 123:
if(resultCode == RESULT_OK){
String type = data.getStringExtra(CodeUtils.RESULT_TYPE);
String result = data.getStringExtra(CodeUtils.RESULT_STRING);
if(type.equals(CodeUtils.RESULT_SUCCESS)){
Toast.makeText(this,result,Toast.LENGTH_SHORT).show();
}else {
Toast.makeText(this,"扫描失败",Toast.LENGTH_SHORT).show();
}
}
break;
default:break;
}
}
Copyright 2018 Winton
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.