简体   繁体   English

在 Android 中通过 Intent 使用 Zxing 扫描条码时如何更改文本?

[英]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?通过意图启动条码扫描器(zxing)时,是否可以更改提示文本“将条码放入取景器内......”?

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:如果它对任何人都有价值,那么如果您决定将 ZXings 库导入 Android Studio,您可以通过以下方式使用 IntentIntegrator 执行此操作:

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.它在我的 Android 上显示为“Positionieren Sie den Barcode innerhalb des Rechtecks”。 So I guess, the text depends on the handhelds locale setting (as ZXing doesn't provide a setting to change the locale locally).所以我想,文本取决于手持设备的区域设置(因为 ZXing 不提供在本地更改区域设置的设置)。

So if you need support for a now unsuported language, I bet you have to get in contact with ZXings dev team.因此,如果您需要对现在不受支持的语言的支持,我敢打赌您必须与 ZXings 开发团队联系。

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");这项工作非常完美,因为我正在使用它 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();
    }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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