Home QR Code News + Newsflash QR Code android code

QR Code android code

E-mail

androidcode

awalkingcity.com recently blogged about creating QR codes on the new T Mobile G1 android platform. The android code uses Googles API to generate the actual QR code. To get started developing your own QR code applications on androd devices just download the android sdk - software development kit from Google. Get you QR Code reader for android here http://www.qrme.co.uk/qr-code-resources/qr-code-readers.html

Original blog post http://awalkingcity.com/blog/?cat=5 . 

To see the sample code click read more. There is also an excellent article at http://awalkingcity.com/blog/?p=116 and a complete android api reference guide at code.google.com.

See our android videos here http://www.qrme.co.uk/android-videos.html

Generate a QR code

encodeButton.setOnClickListener(new OnClickListener(){

public void onClick(View arg0) {

    img.setImageBitmap(QR.this.encodeString(edit.getText().toString()));

}

 

});

private Bitmap encodeString(String input) {

     URL aURL;

     try {

      aURL = new URL("http://chart.apis.google.com/chart?chs=300x300&cht=qr&choe=UTF- 8chl="+URLEncoder.encode(input, "UTF-8"));

      URLConnection conn = aURL.openConnection();

      conn.connect();

      InputStream is = conn.getInputStream();

      BufferedInputStream bis = new BufferedInputStream(is);

      Bitmap bm = BitmapFactory.decodeStream(bis);

      bis.close();

      is.close();

      return bm;

      } catch (MalformedURLException e) {

       e.printStackTrace();

      } catch (IOException e) {

       e.printStackTrace();

      }

     return null;

}

Decode a QR Code

decodeButton.setOnClickListener(new OnClickListener(){

public void onClick(View arg0) {

     try {

      tv.setText(((QR.this.decode(img.getDrawingCache()))));

     } catch (ReaderException e) {

      e.printStackTrace();

     }

}

});

 

private String decode(Bitmap bm) throws ReaderException {

     QRCodeReader reader = new QRCodeReader();

     Result r = reader.decode( new RGBMonochromeBitmapSource(bm));

     return r.getText();

}

 
  SocialTwist Tell-a-Friend
  SocialTwist Tell-a-Friend


Login using Facebook
Complete QR code management

Track your QRMe Code

This is our QRMe code. Register for yours

Scanned 417 times
Last 6 months

JoomlaWatch Stats 1.2.7 by Matej Koval

Countries

17.5%UNITED KINGDOM UNITED KINGDOM
13.9%UNITED STATES UNITED STATES
8.4%GERMANY GERMANY
6.7%BRAZIL BRAZIL
6.1%AUSTRALIA AUSTRALIA
4.2%SPAIN SPAIN
3.6%POLAND POLAND
3.2%NETHERLANDS NETHERLANDS
2.6%ITALY ITALY
2.3%FRANCE FRANCE
2.2%CZECH REPUBLIC CZECH REPUBLIC
2%HUNGARY HUNGARY