I am able to scan and obtain a QR code using ZXING. Based on the QR code obtained, I would like to navigate to a website if it is a URL or add to the contacts if its a contact detail. Are there any functions available in ZXING to do validations on the scanned QR Code?
Most definitely. Within core/ look at ResultParser (see http://code.google.com/p/zxing/source/browse/trunk#trunk%2Fcore%2Fsrc%2Fcom%2Fgoogle%2Fzxing%2Fclient%2Fresult) This is where a raw result string is parsed into something structured. The Barcode Scanner source code in android/ has even more code that then ties in these results to platform actions.
Yes. https://market.android.com/details?id=com.google.zxing.client.androidtest&hl=de
Somewhat beta, but should help you.
Oh sorry, now I got it. Basically a QR-Code is just a String with some fancy stuff arround. If your App scans a QR-Code via xzing, you should only get the information without the fancy stuff. But if its an URL or a Contact or something else you have to decide yourself programatically, because you can store every kind of information inside a QR-Code.
Related
This question already has answers here:
How to launch my Android app from a QR reader?
(2 answers)
Closed 1 year ago.
I have seen some example that people code executable code on a QR code like this https://itsmattkc.com/etc/snakeqr/. I wanted to create a QR code that executes the command to open a specific phone application for any phone (android & IOS).
The process will be like this,
Scan QR code with a phone.
Phone executes the command that stores inside the QR code (code that does something like "start C:\...\specific app" in C language) and open the App or prompt user to download it if the application is not installed on the phone.
Close the window that is used to execute the command(if any).
My question right now is,
What language can be used to code the command that open the phone application like what I stated above?
How can I turn the code into a QR code?
Background A QR code doesn't itself execute anything, at a high level QR code is just a method of serializing an array of bytes into a visual form, the reader can de-serialize the image back into an array of bytes which must then be interpreted.
Generic QR readers will generally assume that the original data represented an encoded string and so will decode the bytes into a string.
The instructions in SnakeQR tell you to use a QR reader that allow you to save the bytes to disk, instead of decoding them into a string, which just demonstrates that the QR code contains binary data and that the data on its own doesn't do anything, the user needs to take that data and complete the next step to action it, but that action is up to the user.
This is when the magic starts to happen, if the QR code represents or contains a URL, then most reader applications will auto-launch a web browser and will navigate to that URL.
In the app development world we can hijack the default behaviour of these QR code readers to interact with the device in 3 ways:
Write a web page that will execute scripts to complete your operation on the device that navigates to that page, host that somewhere globally accessible and store the URL to that page in your QR code.
Use a URI that the device will recognise as an internal location, this post How to launch my android app from a QR reader is describing this process, in the android application API you can define these intents, effectively registering a URI with a specific action.
The specifics to this are out of scope, this question is about the QR code itself, but most operating systems will have a similar process where there are standard actions bound to URIs and there is usually a mechanism for you to create custom bindings.
Write your own proprietary QR Reader application that can natively understand the commands in the QR code and can execute them direct.
In terms of languages that support this, its not a language specific thing, in Android applications the mechanism you want to exploit is Android Intents Tutorial (Android Developers - Intents).
In iOS there have been mixed version of URL bindings over the years, but SiriKit is probably the closest in terms of functionality, its far more restricted than android, but enough to launch apps and pass through arguments.
In Windows OS you can register URI schemes to do the same thing...
When it comes to proprietary logic, we can use all 3 methods to build a seemless experience for the users:
Make a landing web page with a message like "If you see this page then you should install my app for an enhanced experience..." (on this page there should be instructions for how to find and install your app)
Make the QR code a URL to the landing page with the parameters that you want passed to the app as URL parameters.
Build and publish your app, in this app you should register the URI to the landing page with the native device OS so that after the device is installed, your app runs instead of the user going to the landing page. Don't forget to map any parameters as startup arguments for your app.
I want to create an android app by android studio to get information from barcode such as price and name.
the thing is i am new to this so i am asking if i can make a barcode reader that scans ean-13 barcode and get price and name from database like "Open Food Facts", the exact question is how can i make the barcode reader get the price and name ? do i have to link it with some kind of data base ?
btw i am using android studio with kotlin if it helps .
And this is my first topic, i don't know how things works here so if i did anything wrong please be free to point it
You will have to link the bar code scanner with a database if you want to retrieve the information from a given barcode.
For instance, if you are scanning the QR code embedded in a book that has a unique ID, you will then need to have access to the database of all the books mapped with their relevant QR code ID.
Could you share your exact use case here as that might help us understand what you're trying to do here.
I am not sure if this can be done. I am trying to pull a business info (mainly business name) from QR code. I am using zxing and I am able to scan it and get the URL. Now is there any other hidden info such as business name, address ..etc that I can pull from the QR code. If not, then can I use the URL maybe to get some of these info? Pleeease any insight is appreciate to how it can be achieved
PS: Ultimitally, I want the business to be shown on google map. Thats all
If the company name is recorded in a standard format in the QR code, like vCard encoding using the "ORG" attribute, then yes you can parse the raw text you get back by Intent from Barcode Scanner zxing using its ResultParser class. It will detect and parse vCard and you will get an AddressBookParsedResult object with an "org" property with this info.
Otherwise you're talking about guessing from free-form text what the company name is. There's no way to do that with zxing and that's a generally hard problem.
I’m building an Android application that I want to publish only once, but want it to connect to 2 different servers. The application will be downloadable with a QR-code
For example, my friend has a moviedatabase on his own server and I have one. Without manually writing the server url in the application settings, I wanted to modify the .APK file or the QR code, giving it a parameter. So when my friend scans in the QR-code which I make for him, I want his app to connect with his server. When I scan my QR-code I wanted it to connect to mine. Right after the installation of the .APK.
Is this possible? Or are there any suggestions how I can put the server url “somewhere” without entering it manually in the code?
There is another option. Making a textfield that the user can fill by scanning a QR-code. But for me, that is still manually entering the URL.
Any suggestions or advice are welcome.
What is the problem to store server url in preferences and make an extra Activity to grab qr from camera and change the preference
This isn't supported functionality on install. There's no way to link to an Android Market url with extra information to be executed as a post-install script. You can include a QR code scanner in your app (I believe ZXing is open source and/or free to use, for example), and you can have the server info encoded in the QR code. You can save this to any persistent storage (such as SharedPreferences or SQLite) and then use this for all future data requests.
I use ZXing to scan a regular barcode (not QR code) and I get a scanresult string, or to be more precise a number.
When I scan QR codes, it's easy to use the result because it always contains a URL to the Android Market. But how to use the number from a regular barcode? Which "search engine" to use to get the right product?
PS. quering this result number via google.com or Google Shopping returned no product at all
I've never used ZXing, but I see that it supports many barcode types. The type of the barcode will determine where you can look for it (i.e. it depends what you mean by a 'regular' barcode). If it's a UPC barcode, you can use something like this site.
If it's an ordinary 1D barcode, it might turn up in the UPC database. Other than that, there's not a strictly universal barcode database. Amazon's ecommerce API might help (it supports UPC lookup, but I don't know if it supports non-current products), and if you're in the UK then Tesco's has one as well that's worth a look.