简体   繁体   中英

Android: print data on barcode scanner builder window

Ok, so i need to display some of my product's database data on the scanner builder window(as shown in the image) when this product gets scanned. Scanner window results

As you can see in the image, the barcode scanner is displayed, my question is: is it possible to print in this windows some other data except from the product's barcode? if yes how should i move?

this is my windows builder code

public void handleResult(Result result) {
         //myResult= barcode text
         myResult = result.getText();
        AlertDialog.Builder builder = new AlertDialog.Builder(this);
        builder.setTitle("Scan Result");
        builder.setPositiveButton("OK", new DialogInterface.OnClickListener() {

            @Override
            public void onClick(DialogInterface dialog, int which) {

                scannerView.resumeCameraPreview(addquantityactivity.this);
                updateData();
            }
        });
        builder.setNeutralButton("Visit(if url)", new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(myResult));
                startActivity(browserIntent);
            }
        });
        builder.setMessage(result.getText());
        AlertDialog alert1 = builder.create();
        alert1.show();

    }

Do you see where it says builder.setMessage(result.getText()); <--?

This is where you'd set the result. At the moment you're just putting in the result text which is the number. If you want something more, there is where you would put it.

EDIT:

I'm terrible at writing answers. The method you are using is defined here . It takes in a Character Sequence and will display it. Or it can take in an Int and show that.

EDIT2:

As an example of concatenating the barcode with some other information I would do this:

String myMessage = result.getText() + " and some other amazing information about this barcode";

builder.setMessage(myMessage);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM