2013-08-19 2 views
2

단추를 클릭 할 때 Zxing qr 스캐너에 실제로 조각을 넣으려고합니다.Zxing qr 스캐너 onActivityResult에서 int 변수를 비교할 수 없습니다.

Intent intent = new Intent("com.google.zxing.client.android.SCAN"); 
      intent.putExtra("SCAN_MODE", "PRODUCT_MODE");// for Qr code, its 
                  // "QR_CODE_MODE" 
                  // instead of 
                  // "PRODUCT_MODE" 
      intent.putExtra("SAVE_HISTORY", false);// this stops saving ur 
                // barcode in barcode 
                // scanner app's history 
      startActivityForResult(intent, 0); 

내가 직면하고 문제는 아래의 코드에서, 내가 RESULT_OK 및 RESULT_CANCELED 비교할 내의 resultCode를 얻을 수 없습니다 생각이다. 나는 잘한 활동에서 이것을 할 수 있었지만, 내가 조각 클래스에서 구현하고 싶었을 때 그렇게 할 수 없었다.

@Override 
    public void onActivityResult(int requestCode, int resultCode, Intent data) 
    { 
     super.onActivityResult(requestCode, resultCode, data); 
     Log.d("onActivityResult", "Started"); 
     if (requestCode == 0) 
     { 
      if (resultCode == RESULT_OK) 
      { 
       String contents = data.getStringExtra("SCAN_RESULT"); 

       TextView txt_qrCode = (TextView) rootView.findViewById(R.id.txt_helloWorld); 
//    txt_qrCode.setText(contents); 
      } 
      else if (resultCode == RESULT_CANCELED) 
      { 
       // Handle cancel 
      } 
     } 
    } 
+0

This this http://stackoverflow.com/questions/1276635/how-to-include-and-use-zxing-library-in-android-with-eclipse/9108983#9108983 – taxeeta

+0

실제로 의도하고 있습니다. 시장에서 네이티브 애플 리케이션을 zxing. – thhVictor

답변

1

이 질문에 대한 답을 찾았습니다. RESULT_OK 및 RESULT_CANCELED 실제로 활동 내 단편 클래스에 의존하기 때문에

INT android.app.Activity.RESULT_CANCELED = 0 [으로 0x0]

더 활성이 없다. 간단히 말해서 나는 나를 조각 팽창 부모 활동을 얻을 수 있도록 할

if (resultCode == RESULT_OK) 
. 
. 

이 대신

if (resultCode == getActivity().RESULT_OK) 
. 
. 

을 넣어.

+0

'Activity.RESULT_OK' 만 사용해야합니다. 정적 상수입니다. – kcoppock

관련 문제