2017-03-17 8 views
0

QR 코드 판독기가 있으며 qr 코드를 스캔하여 텍스트를 가져올 때 if 함수로 해당 텍스트를 검사하도록하고 싶습니다. 특정 이미지를 표시합니다. 이 문자열로 result.getText().ToString()을 인식하지 못합니다처럼하지만 항상 if 기능에 걸리면 어떤 이유로 ... 내가 당신을 비교 한 위해 .equals() 메서드를 사용한다고 생각QR 코드 판독기의 결과를 문자열로 인식 할 수 없습니다.

public void processPicture(CameraEvent event) { 
     updateLayout("Please wait..."); 

     if (event.getIndex() == 0) { 
      if (event.getData() != null && event.getData().length > 0) { 
       byte[] data = event.getData(); 
       Bitmap bitmap = BitmapFactory.decodeByteArray(data, 0, data.length); 

       int[] intArray = new int[bitmap.getWidth() * bitmap.getHeight()]; 
       //copy pixel data from the Bitmap into the 'intArray' array 
       bitmap.getPixels(intArray, 0, bitmap.getWidth(), 0, 0, bitmap.getWidth(), bitmap.getHeight()); 

       LuminanceSource source = new RGBLuminanceSource(bitmap.getWidth(), bitmap.getHeight(), intArray); 

       BinaryBitmap bbmap = new BinaryBitmap(new HybridBinarizer(source)); 
       Reader reader = new QRCodeReader(); 
       int DelayTime = 5000; 
       boolean error = false; 
       try { 

        Result result = reader.decode(bbmap); 
        Log.d(Constants.LOG_TAG, result.getText()); 
        qc = result.getText().toString(); 

        // updateLayout(result.getText()); 
        if(qc == "zoi"){ 
         Bundle iconBundle = new Bundle(); 
         iconBundle.putInt(Control.Intents.EXTRA_LAYOUT_REFERENCE, R.id.image); 
         iconBundle.putString(Control.Intents.EXTRA_DATA_URI, 
           getUriString(R.drawable.zoiko)); 
         currentlyTakingPicture = false; 
         showLayout(R.layout.layout, new Bundle[] {iconBundle}); 
        } 
       } catch (NotFoundException e) { 
        updateLayout("QR Code Not Found"); 
        error = true; 
        e.printStackTrace(); 
       } catch (ChecksumException e) { 
        e.printStackTrace(); 
        updateLayout(new String[] { 
          "QR Code looks corrupted", 
          "Maybe try again?" 
        }); 
        error = true; 
       } catch (FormatException e) { 
        e.printStackTrace(); 
        updateLayout("That's not a QR Code"); 
        error = true; 
       } 

       if (error) { 
        try { 
         Thread.sleep(DelayTime); 
        } catch (InterruptedException e) { 
         e.printStackTrace(); 
        } 
        currentlyTakingPicture = false; 
        updateLayout(DEFAULT_TEXT); 
       } 
      } 
     } 
    } 

답변

0

\ ...입니다 문자열로. if 조건은 다음과 같습니다. -

if(result.getText().toString().equals("zoi")){ 
//your code here 
}