How to create a QR code for my existing android application? -


i want create qr code existing android application (built in android studio). need id's end & generate qr code view in layout.

please me.

here of sample codes, can refer, values may different depend on mobile phone model. hope help! use zxing library.

private void startscan(context context, string parameter) {                 intent intent = new intent();         intent.setaction("com.motorolasolutions.emdk.datawedge.api.action_softscantrigger");         intent.putextra("com.motorolasolutions.emdk.datawedge.api.extra_parameter", parameter);         context.sendbroadcast(intent);     }  @override     public boolean onkeyup(int keycode, @nonnull keyevent event) {         if ((event.getaction() == keyevent.action_up) && keycode == keyevent.keycode_...) {             startscan(this, "start_scanning");             registerreceiver(new broadcastreceiver() {                  @override                 public void onreceive(context context, intent intent) {                     string code = intent.getextras().getstring("com.motorolasolutions.emdk.datawedge.data_string");                      imageview imageview = (imageview) findviewbyid(r.id.imageview);                     textview textview = (textview) findviewbyid(r.id.textview);                     if ((imageview != null) && (textview != null)) {                                 textview.settext(code);                 // barcode image                 try {                         mbarcodebitmap = encodebarcodeasbitmap(value, barcodeformat.code_128, 200, 100);                         imageview.setimagebitmap(mbarcodebitmap);                                        } catch (writerexception e) {                             }                     }                      unregisterreceiver(this);                 }             }, new intentfilter("com.example.softscanintentaction")); // value must set in datawedge profile (intent output - intent action...)         }         return super.onkeyup(keycode, event);     }  private bitmap encodebarcodeasbitmap(string contents, barcodeformat format, int width, int height) throws writerexception {         string contentstoencode = contents;         if (contentstoencode == null) {             return null;         }         map<encodehinttype, object> hints = null;         string encoding = guessappropriateencoding(contentstoencode);         if (encoding != null) {             hints = new enummap<>(encodehinttype.class);             hints.put(encodehinttype.character_set, encoding);         }         multiformatwriter writer = new multiformatwriter();         bitmatrix result;         try {             result = writer.encode(contentstoencode, format, width, height, hints);         } catch (illegalargumentexception iae) {             // unsupported format             return null;         }         int imgwidth = result.getwidth();         int imgheight = result.getheight();         int[] pixels = new int[imgwidth * imgheight];         (int y = 0; y < imgheight; y++) {             int offset = y * imgwidth;             (int x = 0; x < imgwidth; x++) {                 pixels[offset + x] = result.get(x, y) ? 0xff000000 : 0xffffffff;             }         }          bitmap bitmap = bitmap.createbitmap(imgwidth, imgheight,                 bitmap.config.argb_8888);         bitmap.setpixels(pixels, 0, imgwidth, 0, 0, imgwidth, imgheight);         return bitmap;     } 

Comments

Popular posts from this blog

yii2 - Yii 2 Running a Cron in the basic template -

asp.net - 'System.Web.HttpContext' does not contain a definition for 'GetOwinContext' Mystery -

mercurial graft feature, can it copy? -