QRScanner Assistance with Parse/Int Deferencing

13 Views Asked by At

Just trying to flatten out bugs..

  1. Int can not be dereferenced (on the StartWith Line)
  2. Cannot find symbol method parse(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

There are 1 best solutions below

0
On

Here is the solution:

@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);
}