Question

My main objective is to transfer an image (which resides in a folder in a local web server i.e. http://localhost/image/myimage.jpg) and some info (i.e. name, id, time) associated with the image to the Android App via QRCode (Android App has a QR scanner function).

So far, the App can scan the resulted QR code which point to the image and image can be downloaded successfully into the phone. However, I am stuck at "methods" to transfer the associated info into the phone. How should I do it?

  1. My first thought is to have another QR code which point to a text file containing those info. The App will download the text file via the QR code, parse the data properly and store them into Shared Preferences. Then, the text file can be deleted. The cons here is that I have to produce 2 QR codes.

  2. I can also go with generating a second QR code by encoding the associated info into that QR code directly. The cons is that I still need to produce 2 QR codes.

  3. My 3rd thought is to rename the image before it can be downloaded with it's associated info. Something like http://localhost/image/myimage-name-id-time.jpg Then I can just parse the info from the image's name, store them into Shared Preferences and rename it back properly.

Which one should I go for? what is the standard way to do this? Is there any other way?

Please bear in mind I am new to Android Development. I would appreciate a well elaborated answer. Thanks.

Was it helpful?

Solution

I would go with (3) - rename the image file. There is an alternative though, which may be useful to you.

JPG images can contain EXIF data. This is data which is designed to be read by a machine to give it information about the image.

For example, the location where the image was taken, the time it was taken, the focal mode used, etc.

It would be possible for you to create the images with EXIF tags for name, time, ID, and anything else you wanted.

Using Android, you can call Exif Interface to read the tags from the image.

Very roughly, your code will be something like....

String image = //path to your image.
ExifInterface exif = new ExifInterface(image);
String MyID = exif.getAttribute("MyID");
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top