Skip to content Skip to sidebar Skip to footer

Zxing Onactivityresults Not Firing

I'm trying to pull data from a QR code via zxing using the following code (basically copypasted from a tutorial, with names changed to protect the innocent): //Check fo

Solution 1:

You have following problem in your code

you have written public void onActivityResult(int requestCode, int resultCode, Intent intent) method inside button onclick listener. move it outside.

your code snippet should look something like this

@OverridepublicvoidonCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

            ----
            ----
}

@OverrideprotectedvoidonActivityResult(int requestCode, int resultCode, Intent intent) {
    super.onActivityResult(requestCode, resultCode, intent);

    if (requestCode == 0) {
              if (resultCode == RESULT_OK) {
                 Stringcontents= intent.getStringExtra("SCAN_RESULT");
                 Stringformat= intent.getStringExtra("SCAN_RESULT_FORMAT");
                 // Handle successful scanEditTextpassphrase= (EditText) findViewById(R.id.txtPassphrase);
                 passphrase.setText(contents);
              } elseif (resultCode == RESULT_CANCELED) {
                 // Handle cancel
              }
           }

}

Post a Comment for "Zxing Onactivityresults Not Firing"