0

How do I make the value obtained from scanning a qr code and then put it into a string?

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_qrscanner);
    fragment = (BarcodeFragment)getSupportFragmentManager().findFragmentById(R.id.sample);
    fragment.setScanResultHandler(this);
    btn = ((Button)findViewById(R.id.scan));
    btn.setEnabled(false);

}
Tan Chong Kai
  • 332
  • 1
  • 4
  • 17

1 Answers1

1

Setting the ScanResultHandler you implement an interface, with a callback:

@Override
public void scanResult(ScanResult result) {

}

And there you have the result.

Kenneth
  • 3,957
  • 8
  • 39
  • 62
  • But how do i carry over the value (this) into another activity from the qr code scanner? – Tan Chong Kai Sep 10 '15 at 05:40
  • I think you need to add a few things to your question: your code and your intention. – Kenneth Sep 10 '15 at 05:42
  • I want to take the value which the qr code scanner get after scanner a qr code. Then carrying the value over into another activity. – Tan Chong Kai Sep 10 '15 at 05:45
  • So, basically passing data between activities? http://stackoverflow.com/questions/2091465/how-do-i-pass-data-between-activities-in-android – Kenneth Sep 10 '15 at 05:46
  • Yea but i can't get the value (which is 'this' in the code) into a string . The line from the code : fragment.setScanResultHandler(this); – Tan Chong Kai Sep 10 '15 at 05:51
  • As I said before, in the class you call the setScanResultHandler(this), you need to implement the interface accepted in the method call, I don't know the name of it. When you do that, you also need to implement the metods from the interface, and there you have your result, as I posted above. – Kenneth Sep 10 '15 at 05:53
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/89228/discussion-between-tan-chong-kai-and-kenneth). – Tan Chong Kai Sep 10 '15 at 07:10
  • http://stackoverflow.com/questions/32494654/how-to-take-the-qr-scanner-result-and-make-it-into-a-string/32494887#32494887 maybe it will be clearer on what i am asking – Tan Chong Kai Sep 10 '15 at 08:36