mirror of
https://github.com/zxing/zxing.git
synced 2025-03-05 20:48:51 -08:00
Update IntentIntegrator.java
This commit is contained in:
parent
c103e59b7e
commit
07bdeb9995
|
@ -249,25 +249,50 @@ public class IntentIntegrator {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initiates a scan for all known barcode types.
|
* Initiates a scan for all known barcode types with the default camera.
|
||||||
*
|
*
|
||||||
* @return the {@link AlertDialog} that was shown to the user prompting them to download the app
|
* @return the {@link AlertDialog} that was shown to the user prompting them to download the app
|
||||||
* if a prompt was needed, or null otherwiseo
|
* if a prompt was needed, or null otherwise.
|
||||||
*/
|
*/
|
||||||
public final AlertDialog initiateScan() {
|
public final AlertDialog initiateScan() {
|
||||||
return initiateScan(ALL_CODE_TYPES);
|
return initiateScan(ALL_CODE_TYPES, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initiates a scan only for a certain set of barcode types, given as strings corresponding
|
* Initiates a scan for all known barcode types with the specified camera.
|
||||||
|
*
|
||||||
|
* @param cameraId camera ID of the camera to use
|
||||||
|
* @return the {@link AlertDialog} that was shown to the user prompting them to download the app
|
||||||
|
* if a prompt was needed, or null otherwise.
|
||||||
|
*/
|
||||||
|
public final AlertDialog initiateScan(int cameraId) {
|
||||||
|
return initiateScan(ALL_CODE_TYPES, cameraId);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initiates a scan, using the default camera, only for a certain set of barcode types, given as strings corresponding
|
||||||
* to their names in ZXing's {@code BarcodeFormat} class like "UPC_A". You can supply constants
|
* to their names in ZXing's {@code BarcodeFormat} class like "UPC_A". You can supply constants
|
||||||
* like {@link #PRODUCT_CODE_TYPES} for example.
|
* like {@link #PRODUCT_CODE_TYPES} for example.
|
||||||
*
|
*
|
||||||
* @param desiredBarcodeFormats names of {@code BarcodeFormat}s to scan for
|
* @param desiredBarcodeFormats names of {@code BarcodeFormat}s to scan for
|
||||||
* @return the {@link AlertDialog} that was shown to the user prompting them to download the app
|
* @return the {@link AlertDialog} that was shown to the user prompting them to download the app
|
||||||
* if a prompt was needed, or null otherwise
|
* if a prompt was needed, or null otherwise.
|
||||||
*/
|
*/
|
||||||
public final AlertDialog initiateScan(Collection<String> desiredBarcodeFormats) {
|
public final AlertDialog initiateScan(Collection<String> desiredBarcodeFormats) {
|
||||||
|
return initiateScan(desiredBarcodeFormats, -1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initiates a scan, using the specified camera, only for a certain set of barcode types, given as strings corresponding
|
||||||
|
* to their names in ZXing's {@code BarcodeFormat} class like "UPC_A". You can supply constants
|
||||||
|
* like {@link #PRODUCT_CODE_TYPES} for example.
|
||||||
|
*
|
||||||
|
* @param desiredBarcodeFormats names of {@code BarcodeFormat}s to scan for
|
||||||
|
* @param cameraId camera ID of the camera to use
|
||||||
|
* @return the {@link AlertDialog} that was shown to the user prompting them to download the app
|
||||||
|
* if a prompt was needed, or null otherwise
|
||||||
|
*/
|
||||||
|
public final AlertDialog initiateScan(Collection<String> desiredBarcodeFormats, int cameraId) {
|
||||||
Intent intentScan = new Intent(BS_PACKAGE + ".SCAN");
|
Intent intentScan = new Intent(BS_PACKAGE + ".SCAN");
|
||||||
intentScan.addCategory(Intent.CATEGORY_DEFAULT);
|
intentScan.addCategory(Intent.CATEGORY_DEFAULT);
|
||||||
|
|
||||||
|
@ -284,6 +309,11 @@ public class IntentIntegrator {
|
||||||
intentScan.putExtra("SCAN_FORMATS", joinedByComma.toString());
|
intentScan.putExtra("SCAN_FORMATS", joinedByComma.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// check requested camera ID
|
||||||
|
if (cameraId > -1) {
|
||||||
|
intentScan.putExtra("SCAN_CAMERA_ID", cameraId);
|
||||||
|
}
|
||||||
|
|
||||||
String targetAppPackage = findTargetAppPackage(intentScan);
|
String targetAppPackage = findTargetAppPackage(intentScan);
|
||||||
if (targetAppPackage == null) {
|
if (targetAppPackage == null) {
|
||||||
return showDownloadDialog();
|
return showDownloadDialog();
|
||||||
|
|
Loading…
Reference in a new issue