QRScanner协助Parse / Int Deferencing

时间:2017-11-19 22:21:14

标签: java android

试图消除错误..

  1. Int无法解除引用(在StartWith线上)
  2. 找不到符号方法解析(int)

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == BARCODE_READER_REQUEST_CODE) {
        if (resultCode == CommonStatusCodes.SUCCESS) {
            if (resultCode.Startswith("http://") || resultCode.startsWith("https://")) {
                Intent browserIntent = new Intent(Intent.ACTION_VIEW, URI.parse(resultCode));
                startActivity(browserIntent);
            }
    

1 个答案:

答案 0 :(得分:0)

以下是解决方案:

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == BARCODE_READER_REQUEST_CODE) {
        if (resultCode == CommonStatusCodes.SUCCESS) {
            if (data != null) {
                Barcode barcode = data.getParcelableExtra(BarcodeCaptureActivity.BarcodeObject);
                String value = barcode.displayValue;
                if (value.startsWith("http://") || value.startsWith("https://")) {
                    Intent i = new Intent(Intent.ACTION_VIEW);
                    i.setData(Uri.parse(value)); 
                    startActivity(i); 
                }
            } else 
               {
                   Log.e("your_tag","no value captured"); 
               }
        } else Log.e("your_tag","barcode error "); 
    } else super.onActivityResult(requestCode, resultCode, data);
}