Tuesday 3 February 2015

QR Codes

You may have heard and seen the QR Code in your real life so many times. But have you ever tried to know about it? What is it? How it works? Etc.

Well, Today I am here to share some knowledge about QR Code. So let's start !

What is a QR Code?


           Quick Response Codes are a type of two-dimensional barcode that can be read using smartphones and dedicated QR reading devices, that link directly to text, emails, websites, phone numbers and more! You may have even got to this site by scanning a QR code! A QR code uses four standardized encoding modes (numeric, alphanumeric, byte / binary) to efficiently store data; extensions may also be used.

           A QR code consists of black modules (square dots) arranged in a square grid on a white background, which can be read by an imaging device (such as a camera) and processed using Reed–Solomon error correction until the image can be appropriately interpreted. The required data are then extracted from patterns present in both horizontal and vertical components of the image.

          QR codes are huge in Japan and across the East, and are slowly beginning to become commonplace in the West. Soon enough you will see QR codes on product packaging, shop displays, printed and billboard advertisements as well as in emails and on websites. The scope of use for QR codes really is huge, particularly for the marketing and advertising of products, brands, services and anything else you can think of.

Benefits of QR Code:

       QR Codes offer a number of benifits over traditional barcodes that increase their flexibility, reliability and their ease of use. When you combine these benifits, it also results in a reduced cost of implementation which has help drive their popularity. To name only a few of these benifts:
  • High Capacity
  • Require Less Space
  • Dirst And Damage Resistant
  • Readable From Any Direction
  • Structured Appending
Here are some samples of QR code:



How is a QR Code different from a normal 1D UPC barcode?

       Ordinarily we think of a barcode as a collection of vertical lines; 2D Barcodes or QR Codes are different in that the data is stored in both directions and can be scanned vertically OR horizontally.

      Whilst a standard 1D Barcode (UPC/EAN) stores up to 30 numbers, a QR Barcode can store up to a massive 7,089! It is this massive amount of data that enables links to such things as videos, Facebook or Twitter pages or a plethora of other website pages.

Why Should I Learn About Them?

          The reason you should know about them, is that their existence is intended to make things more convenient and more interactive for you. They simplify tasks such as getting someone’s contact details from a business card onto your phone or to giving away your own details using an on screen QR Code.

          Technologies such as NFC offer an alternative but NFC requires specific hardware that isn’t as widely available. Other big players such Microsoft have backed alternatives but these have failed and QR Codes continue to dominate.


What Makes QR Codes Different?

                  The first thing you will notice about a QR Code is that it’s made up of many small squares rather than the lines you see in a traditional UPC barcode. The advantage of this is that whereas with a traditional barcode data is stored only horizontally (1D), a QR Code is able to store data both horizontally and vertically (2D). This greatly increases the amount of data the QR Code can store.

To put this into perspective, a 1D barcode is able to store around 20 Digits whereas a QR Code can store 7089 Digits or 4296 Characters of text. This enables the code to store full contact cards or URLs as well as many other data types.

                  But having the ability to store data in 2 Dimensions doesn’t just mean you should cram more data in unnecessarily. Sometimes there is a need to store only a few digits of data. In this case, the QR Code allows you to store the same data but in a much smaller space.This additional capacity in a QR Code also allows for some other important features. These include the ability to scan a code in any rotation (upside down for example) and also allows a code to include error correction so that if damaged (to a certain extent) the data within can still be read.

What can be encoded into a QR Code?

         QR Codes are quite versatile, they are able to store many different types of data. Each QR Code has a section dedicated to telling the reader what sort of data it holds. This allows for different data types to be encoded and decoded with ease. The following are some of the most common data types you will come across.
  • Contact Data– Data is stored in a contact card and can include a person’s name, phone number, email address, website and others.
  • Calendar Data– This can include a calendar appointment that can be saved to the diary of someone scanning the code, a party invite for example.
  • URL– this is simply a URL that when scanned, would be used by the browser on a smartphone or similar device to display a given webpage.
  • Email Address– this could be used to open a blank email with a predefined subject and recipient when scanned.
  • Phone Number– a simple phone number that can be dialled directly after scanned
  • SMS– a sms could be composed ready to send with a given recipient
  • Plain Text– simply text that may not have a predefined function but could be used by a bespoke application to carry out any given task.
  • Geo Location– A link to a location that when scanned, can be processed by the reader and used to give directions to an event your promoting for example.
Where can QR Codes be placed?


              The answer to this is almost anywhere! QR Code printing can be done in newspapers, magazines, brochures, leaflets and on business cards. Further to this they can be put on product packaging or labels, or on billboards or even walls. You could even tattoo a QR Code on your body – now that would be an interesting take on giving a girl/guy your number in a bar!


           You can use QR Codes on a website but they should not generally be used as a substitute for an old-fashioned hyperlink because obviously the user is already online and doesn't really want to fiddle around with their phone only to find a website they could have just clicked through to in half the time.


How can I make a QR Code?

You can make your own QR Codes using designated 2D barcode generators, some of which are listed below; however you should first consider why it is that you want a QR Code and how you will use it.
QR Code generators that are currently available:







How Do I Use A QR Code?

              It’s relatively straight forward to use / scan a QR Code. You can do so with special equipment or by using a smartphones camera. At the most it should take 5 seconds to scan a code and process its data. The scanning process consist of you basically taking an image of the code and the device running it through an algorithm that extracts its data.



QR Code File Formats
You can use the following file formats when creating a QR Code:
  • HTML Code
  • PNG File
  • Tiff File
  • SVG
  • EPS
PNG files work particularly well as they can be resized very easily, meaning that you can easily scale the QR Code depending on where you want to put it.


Do QR Codes Have To Be A Certain Size?

             No, a QR Code doesn’t have to be a set size and can be printed to any required size.
The surface area of a QR Code is only limited by its environment and expected use combined with the resolution of the scanning device, there isn’t a technical limitation.

          The amount of data a QR Code can store is also not related to its surface area, its determine by the number of rows and columns the code contains which in turns determines the number of small squares you will see when looking at the code.

Are QR Codes Reliable?

          QR Codes are quite reliable, once a QR Code is printed it will not lose the data it holds unless the material it’s printed on is damaged. Even then, QR Codes have a failsafe build into them that helps ensure minimal data loss.

         QR Codes can make use of 4 different levels of error correction. This is set when the code is created and the error correction itself does take up a chunk of data within the code, so if you have a lot of data to store in 1 code, you may not have the option to use error correction.

         The maximum level of protection is 30%. This means that up to 30% of the code can be corrupt or missing and the scanner can still read the code.


          You may have seen some QR Codes where logos or letters are included in the actual code, its error correction that allows this. The code can be created and then a section of the code remove to include an image. Error correction ensures the code is still readable.


Who Invented QR Codes And Why?

Denso-Wave - a subsidiary of the Toyota Group - are attributed with the creation of the QR Code as far back as 1994. Originally it was designed to be used to track parts in the vehicle manufacturing industry, but its use has since grown tremendously.

    In 1994 an automotive company called Denso-Wave (a subsidiary of Toyota Group) come up with a new barcode that allowed more data to be encoded without increasing the size (dimensions / surface area) of existing barcodes. In the main, this was done by including a second dimension. The QR Code was born.


             Nokia spotted QR Codes and was first to implemented a scanner into Mobile phones. Once mobile devices (something that almost everyone carries) were able to scan codes easily, the technology really began to gain momentum. Most Smartphone’s today have apps available that allows the average user to scan a QR Code.

            QR stands for “Quick Response” as the codes were designed to very quickly present data to the scanning device. It takes only a few seconds to scan a QR Code and retrieve the data held within and most of that time is taken by your camera lenses focusing.



What Are The Alternatives To QR Codes?


             There are many alternatives to QR Codes, Some more successful than others.
Smartphones are playing a big part in driving the popularity of QR Codes. The flexibility of smartphones means many QR Code alternatives can coexist without the need for expensive hardware. The user simply needs to install an app allowing them to use the standard of their choice. Most apps support multiple formats.

Below are some links to the most common alternatives that exist.

  • Blipper– Claims to instantaneously convert anything in the real world into an interactive wow experience.
  • MS TagMicrosoft Tag– These tags link back to a central database where you specify the content they contain. This is great if the content is to regularly change as saves you recreating multiple tags.
  • Google Goggles– Very versatile allowing you to take photos of anything, it even solves Suduko puzzles
  • MaxiCodeMaxiCode– 2D barcode using circles rather than squares
  • Data Matrix– Another Similar alternative, Can hold about half as much data as a QR Code
  • EZ CodeEZ Code– Small code that decodes a reference that's looked up on a central database pulling back relevant content.
  • Most of these different standards will contain much of the same features. Some are newer than others and designed for slightly different purposes. For the time being, QR Codes remain the most popular.

Monday 2 February 2015

Difference between “?attr/” and “?android:attr/” in android

Hello Friends,

 Today i am going to share with you one of the concept of an android which is less documented. And the difference of it and in what scenario you can utilize it.


?android: --Is a reference to an item declared in the current Theme*. An example can show this best.  I like to think of these as style 'variables', or global attributes that can are set in the main Theme declaration.Let's say we've got a style that's currently being applied to a stock Widget, the ExpandableListView style. For our app, we want to override the groupIndicator and the childDivider styles.
First of all the basic:

@android: -- This is a reference to existing resource or previously declared style (or drawable or dimension, etc).

 <style name="Widget.Holo.ExpandableListView" parent="Widget.Holo.ListView">  
  <item name="groupIndicator">@android:drawable/expander_group_holo_dark</item>  
  ...  
  <item name="android:childDivider">?android:attr/listDivider</item>  
 </style>  

--groupIndicator is using an @android reference to a stock drawable.  To override this, we'll need have create a new style (that has a parent of Widget.Holo.ExpandableListView) and override the groupIndicator with a new drawable.  We'll then need to set the style on our ExpandableListView, or set the style for ExpandableListViews to use the new style or pass it to the style to the view directly via the constructor.

--childDivider is using a ?android attribute reference.  This is a lot easier to override.  In the main app Theme, add an item that sets this property.
 <style name="MyAppTheme" parent="android:Theme.Holo">  
    <item name="android:listDivider">@drawable/list_divider_custom</item>  
  </style>  

The listDivider has been updated for every style that's using the ?listDivider style attribute. Wherever a ?listDivider attribute has been referenced, will now be replaced with your custom list divider drawable.

To create your own layout attributes, you'll need to create an attribute for it first.

First declare the Theme styleable in attr.xml
 <declare-styleable name="Theme">  
   <attr name="customAttributeSize" format="reference|dimension">  
 </declare-styleable>  

Then add it to your project's themes.xml, and define a style for it.
 <style name="MyAppTheme" parent="android:Theme.Holo">  
   ...  
   <item name="customAttributeSize">24dp</item>  
   ...  
 </style>  
 <style name="TextAppearance.Custom" parent="TextAppearance">  
  <item name="android:textSize">?customAttributeSize</item>  
 </style>  

There's no need to namespace the reference with android: as it's a locally declared attribute.

For all the styles and themes that can be styled with an attribute, check out the source for attributes at attr.xml andthemes.xml.  The styles that compose a theme (and use attributes) are here.


?attr/xyz
Defines and refers to the value of an attribute which you have defined on your own in your application.

?android:attr/xyz

Refers to the values of an attribute which are already available in android built-in. More specifically, the ? implies an extra level of indirection. Think of it as dereferencing an attribute to fetch the resource it points to rather than referring to the attribute itself. You see this with ?android:attr/foo
Which is the best practice to use is depends on what properties you are using and if it is available in built-in android system then you can use it otherwise you can define on your own.