开发者

Encode contact info (MeCard) on Android using ZXing

开发者 https://www.devze.com 2023-03-27 04:09 出处:网络
I need to create QR code from contact info which is in MeCard format. I need to encode the following field:

I need to create QR code from contact info which is in MeCard format. I need to encode the following field:

  • Name (N:)
  • Url (URL:)
  • Note (NOTE:)

I can correctly create all 3 fields using ZXing QR Code Generator (here is the generated QR code from the example below). However it doesn't work with ZXing app on Android Emulator. I'm using this snippet:

Intent i = new Intent("com.google.zxing.client.android.ENCODE");
Bundle data = new Bundle();
data.putString(Contacts.Intents.Insert.NAME, "name1");
data.putString("url", "h开发者_如何学编程ttp://www");
//data.putString(Contacts.Intents.Insert.POSTAL, "http://www");
data.putString(Contacts.Intents.Insert.NOTES, "xyz");
i.putExtra("ENCODE_TYPE", "CONTACT_TYPE");
i.putExtra("ENCODE_DATA", data);
startActivity(i);

The result: ZXing app only encode the name field.

Encode contact info (MeCard) on Android using ZXing

1.) How can I solve this issue? Hopefully without dumping everything in name field.

2.) Are there any alternative library support encoding? ZXing seem to be the most popular.


You're not doing anything wrong, it's that the Intent does not support a note or URL.


it's possible to encode url. just use: data.putString("email","http://www.xyz.com");

0

精彩评论

暂无评论...
验证码 换一张
取 消