| class info |
| com.huawei.hms.hmsscankit.ScanUtil |
| 扫码工具类,用于检测权限并启动扫码界面,提供Default View和Bitmap两种扫码方式,同时提供二维码生成接口 |
| Type | Name | Desc |
| int | SUCCESS | 可以启动扫码界面. |
| int | ERROR_NO_CAMERA_PERMISSION | 没有相机权限 |
| int | ERROR_NO_READ_PERMISSION | 没有读文件权限 |
| String | RESULT | 定义结果键值 |
| Constant |
| public static final int SUCCESS |
| 可以启动扫码界面 Constant Value: 0 |
| Constant |
| public static final int ERROR_NO_CAMERA_PERMISSION |
| 没有相机权限 Constant Value: 1 |
| Constant |
| public static final int ERROR_NO_READ_PERMISSION |
| 没有读文件权限 Constant Value: 2 |
| Constant |
| public static final String RESULT |
| 定义结果键值 Constant Value: SCAN_RESULT |
| Method |
| public static int startScan(android.app.Activity activity, int requestCode, HmsScanAnalyzerOptions option) |
| Default View mode方式扫码接口,检测扫码需要的相机权限和存储权限,若有权限则跳转到由Scan Kit定义的扫码界面,若没有权限直接返回 |
Parameters
| Parameter name | Parameter desc |
| activity | 请求扫码的activity |
| requestCode | 扫码请求的请求码,用于鉴定activity返回时是否从扫码界面返回 |
| option | 扫码格式选项 |
Return
| Type | desc |
| int | 扫码请求结果状态,SUCCESS、ERROR_NO_CAMERA_PERMISSION、ERROR_NO_READ_PERMISSION分别代表请求成功、没有相机权限、没有存储权限 |
| Method |
| public static HmsScan[] decodeWithBitmap(android.content.Context context, android.graphics.Bitmap bitmap, HmsScanAnalyzerOptions format) |
| Bitmap方式解码接口 |
Parameters
| Parameter name | Parameter desc |
| context | 请求上下文,一般可用当前在调用的Activity对象,例如MainActivity.this |
| bitmap | 待解码的图片,为保证解码效果最佳,建议图片大小为960px×540px ~ 1920px×1080px,图片大小不要超过50M |
| format | 指定的扫码格式 |
Return
| Type | desc |
| HmsScan[] | 解码图片结果 |
public static android.graphics.Bitmap buildBitmap(String content, int type, int width, int height, HmsBuildBitmapOption options) throw WriterException
生成一维码/二维码接口
| Type | desc |
content | 码内容 |
type | 码制式 |
width | 码的宽度 |
height | 码的高度 |
options | 生成码参数选项 |
Return
| Type | desc |
| android.graphics.Bitmap | 生成的码图 |
Throws
| Type | desc |
| WriterException | 生成码异常 |