简体   繁体   中英

How to change text when scanning barcodes with Zxing via intent in Android?

Is it possible to change the prompt text that says "place the barcode inside the viewfinder..." when launching the Barcode scanner (zxing) via intent?

Intent intent = new Intent("com.google.zxing.client.android.SCAN")

I want to have a prompt in my language, how should I do that?

Yes, plain and simple:

intent.putExtra("PROMPT_MESSAGE", "Your Text Here");

If it's worth to anyone, here's how you do it with IntentIntegrator if you decided to import ZXings libraries to Android Studio:

integrator.addExtra("PROMPT_MESSAGE", "Your message here");

Developer here. No sorry you can't do that. But yes if all you mean is you want to contribute a new translation, send us the text.

It reads "Positionieren Sie den Barcode innerhalb des Rechtecks" on my Android. So I guess, the text depends on the handhelds locale setting (as ZXing doesn't provide a setting to change the locale locally).

So if you need support for a now unsuported language, I bet you have to get in contact with ZXings dev team.

The proper and modern way to do it is

IntentIntegrator scanIntent = new IntentIntegrator(this);
scanIntent.setPrompt("TEXT THAT YOU WANT TO SHOW");

With this work perfectly 'cause i'm using it integrator.setPrompt("Here your text");

and then....when you clicked (mean on result....) you can change the prompt to retry or continue...in this way:

builder.setTitle("Scan Result");
builder.setPositiveButton("Continue", new DialogInterface.OnClickListener() {
    @Override
    public void onClick(DialogInterface dialog, int which) {
          // here your new intent or other...like blabla();
    }
}).setNegativeButton("Retry",new  DialogInterface.OnClickListener() {
    @Override
    public void onClick(DialogInterface dialog, int which) {
         //even here new itent like  blablabla();
    }

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