摄像头扫码

接口描述

该接口用设备硬件摄像头并展示相应页面,扫码成功之后关闭页面。三方app可根据需要自行调用进行扫码。

接入方式

PnrService.getInstance(getApplicationContext()).doScan(isFront, new PnrTransListener(){
        @Override
        public void onResult(String response) {
                Timber.e(response);
                Map resultMap = new Gson().fromJson(response, Map.class);
                String responseCode = resultMap.get(PnrResponseKey.KEY_RESPONSECODE).toString();
                if ("00".equals(responseCode)){
                        Timber.e("扫码成功:" + resultMap.get("code").toString());
                }else {
                        Timber.e("扫码失败:" + resultMap.get(PnrResponseKey.KEY_MESSAGE).toString());
                }
        }
});

请求参数

  • listener 为结果监听,不能为空;
    onResult(String response) 为结果回调, response 为json串,值参见 返回结果
  • isFront 为boolean值,
    true:前置摄像头,false:后置摄像头

返回结果

  • response 为json字符串。
    其内字段如下:
字段名称 中文描述 数据类型 要求 说明
responseCode 系统返回码 String M 参见 系统返回码
message 错误信息 String C 当返回码为非00时出现
code 扫码结果 String C 扫到的二维码或条码值,当返回码为00时出现

Demo参考

Demo参考