Skip to content Skip to sidebar Skip to footer

How Make Qr Code From Object Of A Class Or Several Data

I was looking for QR code example. And I found the below link for creating QR code from a string. This solution is working fine but if I have a class lets say Student and have fiel

Solution 1:

A QR code can contains arbitrary text, so you can implement a toString/fromString serializer/desserializer in your Student class.

A QRCode can contains up to 4296 alpha-numeric chars (be careful with this limit)

A suggestion : you can use Json format since there a lot of libraries available to help you in serialization/desserialization process.


If you decide to use Json : you can use the gson library.

Serialization is as simple as calling

publicStringserialize(){
    returnnewGson().toJson(this);
}

And for deserialization,

public static Student deserialize(String jsonString){
    new Gson().fromJson(jsonStr, Student.class);
}

more about Json on Android here

Solution 2:

You have to find some way to serialise your class (http://en.wikipedia.org/wiki/Serialization)

You can consider JSON but using some binary format like protobuffers (https://developers.google.com/protocol-buffers/) you will be able to fit more data into qrcodes of the same size.

Post a Comment for "How Make Qr Code From Object Of A Class Or Several Data"