SHARE
TWEET

Untitled

a guest Jun 16th, 2019 64 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // called from within main activity's `onCreate()` method
  2.  
  3.     if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
  4.         Intent[] intentArray = new Intent[2];
  5.         intentArray[0] = getIntent(); // application's main activity
  6.         intentArray[1] = new IntentIntegrator(this).createScanIntent(); // zxing library
  7.  
  8.         ShortcutManager shortcutManager = getSystemService(ShortcutManager.class);
  9.         ShortcutInfo scanShortcut = new ShortcutInfo.Builder(this, "scanQr")
  10.                 .setShortLabel("Scan QR Code")
  11.                 .setLongLabel("Scan QR Code")
  12.                 .setIcon(Icon.createWithResource(this, R.drawable.ic_scan_qr_black_24dp))
  13.                 .setIntents(intentArray)
  14.                 .build();
  15.  
  16.         shortcutManager.setDynamicShortcuts(Arrays.asList(scanShortcut));
  17.     }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top