예제 #1
0
 public final AlertDialog initiateScan(Collection<String> desiredBarcodeFormats) {
   Intent intentScan = new Intent(BS_PACKAGE + ".SCAN");
   intentScan.addCategory(Intent.CATEGORY_DEFAULT);
   // check which types of codes to scan for
   if (desiredBarcodeFormats != null) {
     // set the desired barcode types
     StringBuilder joinedByComma = new StringBuilder();
     for (String format : desiredBarcodeFormats) {
       if (joinedByComma.length() > 0) {
         joinedByComma.append(',');
       }
       joinedByComma.append(format);
     }
     intentScan.putExtra("SCAN_FORMATS", joinedByComma.toString());
   }
   String targetAppPackage = findTargetAppPackage(intentScan);
   if (targetAppPackage == null) {
     return showDownloadDialog();
   }
   intentScan.setPackage(targetAppPackage);
   intentScan.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
   intentScan.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
   attachMoreExtras(intentScan);
   startActivityForResult(intentScan, REQUEST_CODE);
   return null;
 }
예제 #2
0
 /** Initiates a scan for all known barcode types with the default camera. */
 public final void initiateScan() {
   startActivityForResult(createScanIntent(), REQUEST_CODE);
 }