Create QRCode Image for Android

In my application, I want to create a QRCode show image on an Android screen (no internet access). I currently know how to encode a barcode scanner in my application, here is the code for my scanner

Intent intent = new Intent("com.google.zxing.client.android.SCAN");
            intent.putExtra("SCAN_MODE", "QR_CODE_MODE");
            startActivityForResult(intent, 0);

      

however I also need to generate a QRCode image, I have a bit of research and I got this (absolutely no idea how to encode, I'm just a student> <)

com.google.zxing.qrcode.encoder

      

Can someone show me how to create a QRCode image for Android, thanks a lot

+3


source to share


1 answer


Here is the method that will be coded for you.

private void encodeBarcode(String type, String data) {
  Intent intent = new Intent("com.google.zxing.client.android.ENCODE");
  intent.putExtra("ENCODE_TYPE", type);
  intent.putExtra("ENCODE_DATA", data);
  startActivity(intent);
}

      

Here is a usage example



     encodeBarcode("TEXT_TYPE", "http://androidninja.me");

      

ZXingTestActivity.java contains some more examples including all parameters for the type.

+4


source







All Articles