Android扫码项目 扫描链接二维码时 怎么做到直接跳转 不出现扫描结果页面

2025-04-16 14:19:30
推荐回答(1个)
回答1:

  1. 你把扫描之后得到数据那行代码找到

  2. 进行相关操作(比如跳转)

  3. 如果没记错的话,将扫描结果显示出来的操作也是在1那行代码后面进行的


  4. 	/**
     * 处理扫描结果
     * 
     * @param result
     * @param barcode
     */
    public void handleDecode(Result result, Bitmap barcode) {
    inactivityTimer.onActivity();
    playBeepSoundAndVibrate();
    // HashMap hashMap = new HashMap();
    // String phoneNum = (String) hashMap.get("phoneNum");
    // int shorpId = (Integer) hashMap.get("shorpId");
    // String phoneNum=(String) result.getResultMetadata().get("phoneNum");
    // int shorpId =(Integer) result.getResultMetadata().get("shorpId");
    String longtext = result.getText();
    String[] longtext1 = longtext.split("\\-");
    // 电话号码
    String phoneNum = longtext1[0];
    // 用户id
    int shorpId = Integer.parseInt(longtext1[1]);
    System.out.println("phoneNum:" + phoneNum);
    // System.out.println("shorpId:" + shorpId);
    // UserManager.getInstance().setErweimaId(shorpId);
    // UserManager.getInstance().setErweimaPhoneNum(phoneNum);
    if (phoneNum.equals("")) {
    Toast.makeText(MipcaActivityCapture.this, "Scan failed!",
    Toast.LENGTH_SHORT).show();
    } else {
    Intent resultIntent = new Intent();
    Bundle bundle = new Bundle();
    bundle.putString("result", phoneNum);
    // bundle.putParcelable("bitmap", barcode);
    resultIntent.putExtras(bundle);
    this.setResult(RESULT_OK, resultIntent);
    }
    MipcaActivityCapture.this.finish();
    // openActivityIn(InputMoneyActivity.class);

    }