Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Encode contact info (MeCard) on Android using ZXing

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", "http://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.

enter image description here

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.

like image 755
user802421 Avatar asked Nov 25 '22 10:11

user802421


1 Answers

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

like image 166
Sean Owen Avatar answered Dec 15 '22 23:12

Sean Owen