0

am scan Qr code/Barcode, so I want to scan different qr code/barcode and arrange them is String listview.

Example I want to setText() like this ,scanNumber1,scanNumber2,....,..., so far i have managed to scan that Qr Code/Barcode but when i scan the next number it remove the first one, so I want ti arrange those number.

here is my code

public void scanCode(View view){
    IntentIntegrator intentIntegrator = new IntentIntegrator(this);
    intentIntegrator.initiateScan();

}
@Override
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {

    IntentResult intentResult = IntentIntegrator.parseActivityResult(requestCode, resultCode, data);
       String scanNumber=intentResult.getContents();
    if (intentResult != null) {

        if(intentResult.getContents() == null) {

            Toast toast = Toast.makeText(getApplicationContext(), "Scan The QR code/Barcode", Toast.LENGTH_LONG);
            toast.show();

        }
        //validate ur scan numbers
        else if (intentResult.getContents().length() == 10) {
            textView1.setText(intentResult.getContents());
        }
        else if(intentResult.getContents().length() == 12){
            textView2.setText(intentResult.getContents());
        }
        else {
            Toast toast = Toast.makeText(getApplicationContext(), "That Number is Out Of Our Range", Toast.LENGTH_LONG);
            toast.show();
        }
    }

    super.onActivityResult(requestCode, resultCode, data);

}

and this is output enter image description here

so I want on that Slave to appear like ,scanNumber1,scanNumber2,....,...,

1 Answer 1

1

you can use a global JointoString function object to achieve the desired behaviour i.e. "barcode1","barcode2"....

ArrayList<String> results = new ArrayList<String>()

when you receive the result try

results.add(<value>)

while displaying to text view use

textView.setText(results.joinToString(","))
Sign up to request clarification or add additional context in comments.

5 Comments

brother, the first line ` you can use a global JointoString function object to achieve the desired behaviour i.e. "barcode1","barcode2".... ArrayList<String> results = new ArrayList<String>()` i put where, onCreate method or ?
if you would like to see my code you can link my zoom, Join Zoom Meeting zoom.us/j/96095658643?pwd=eTU3d3VEOTlFazU1RzB3eWJzMk41dz09 Meeting ID: 960 9565 8643 Password: 5nvWbe
you can create it as private class property , i.e. outside of onCreate()
Brother, can you show me how? I dont have big experience of in android studio
If you are interested i can show you my code and once is works then you can update the answer here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.