Advertisement
Guest User

Untitled

a guest
Jun 16th, 2019
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  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. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement