Issue 691 specify Barcode Scanner package to handle intents

git-svn-id: https://zxing.googlecode.com/svn/trunk@1704 59b500cc-1b3d-0410-9834-0bbf25fbcc57
This commit is contained in:
srowen 2011-01-18 15:41:17 +00:00
parent 3b498b099a
commit 912a7f1d56
3 changed files with 10 additions and 4 deletions

View file

@ -23,6 +23,7 @@ Eduardo Castillejo (University of Deusto)
Eric Kobrin (Velocitude) Eric Kobrin (Velocitude)
Erik Barbara Erik Barbara
Fred Lin (Anobiit) Fred Lin (Anobiit)
gcstang
Hannes Erven Hannes Erven
hypest (Barcorama project) hypest (Barcorama project)
Isaac Potoczny-Jones Isaac Potoczny-Jones

View file

@ -35,7 +35,7 @@
deprecation="true" deprecation="true"
includeantruntime="false"> includeantruntime="false">
<classpath> <classpath>
<pathelement location="${android-home}/platforms/android-3/android.jar"/> <pathelement location="${android-home}/platforms/android-7/android.jar"/>
</classpath> </classpath>
</javac> </javac>
<jar jarfile="android-integration.jar" basedir="build"/> <jar jarfile="android-integration.jar" basedir="build"/>

View file

@ -74,6 +74,7 @@ import android.net.Uri;
* @author Fred Lin * @author Fred Lin
* @author Isaac Potoczny-Jones * @author Isaac Potoczny-Jones
* @author Brad Drehmer * @author Brad Drehmer
* @author gcstang
*/ */
public final class IntentIntegrator { public final class IntentIntegrator {
@ -85,6 +86,8 @@ public final class IntentIntegrator {
public static final String DEFAULT_YES = "Yes"; public static final String DEFAULT_YES = "Yes";
public static final String DEFAULT_NO = "No"; public static final String DEFAULT_NO = "No";
private static final String PACKAGE = "com.google.zxing.client.android";
// supported barcode formats // supported barcode formats
public static final String PRODUCT_CODE_TYPES = "UPC_A,UPC_E,EAN_8,EAN_13"; public static final String PRODUCT_CODE_TYPES = "UPC_A,UPC_E,EAN_8,EAN_13";
public static final String ONE_D_CODE_TYPES = PRODUCT_CODE_TYPES + ",CODE_39,CODE_93,CODE_128"; public static final String ONE_D_CODE_TYPES = PRODUCT_CODE_TYPES + ",CODE_39,CODE_93,CODE_128";
@ -166,7 +169,8 @@ public final class IntentIntegrator {
CharSequence stringButtonYes, CharSequence stringButtonYes,
CharSequence stringButtonNo, CharSequence stringButtonNo,
CharSequence stringDesiredBarcodeFormats) { CharSequence stringDesiredBarcodeFormats) {
Intent intentScan = new Intent("com.google.zxing.client.android.SCAN"); Intent intentScan = new Intent(PACKAGE + ".SCAN");
intentScan.setPackage(PACKAGE);
intentScan.addCategory(Intent.CATEGORY_DEFAULT); intentScan.addCategory(Intent.CATEGORY_DEFAULT);
// check which types of codes to scan for // check which types of codes to scan for
@ -193,7 +197,7 @@ public final class IntentIntegrator {
downloadDialog.setMessage(stringMessage); downloadDialog.setMessage(stringMessage);
downloadDialog.setPositiveButton(stringButtonYes, new DialogInterface.OnClickListener() { downloadDialog.setPositiveButton(stringButtonYes, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialogInterface, int i) { public void onClick(DialogInterface dialogInterface, int i) {
Uri uri = Uri.parse("market://search?q=pname:com.google.zxing.client.android"); Uri uri = Uri.parse("market://search?q=pname:" + PACKAGE);
Intent intent = new Intent(Intent.ACTION_VIEW, uri); Intent intent = new Intent(Intent.ACTION_VIEW, uri);
activity.startActivity(intent); activity.startActivity(intent);
} }
@ -272,7 +276,8 @@ public final class IntentIntegrator {
CharSequence stringButtonNo) { CharSequence stringButtonNo) {
Intent intent = new Intent(); Intent intent = new Intent();
intent.setAction("com.google.zxing.client.android.ENCODE"); intent.setAction(PACKAGE + ".ENCODE");
intent.setPackage(PACKAGE);
intent.putExtra("ENCODE_TYPE", "TEXT_TYPE"); intent.putExtra("ENCODE_TYPE", "TEXT_TYPE");
intent.putExtra("ENCODE_DATA", text); intent.putExtra("ENCODE_DATA", text);
try { try {