watashiyoga / simplescan Goto Github PK
View Code? Open in Web Editor NEWAutomatically exported from code.google.com/p/simplescan
Automatically exported from code.google.com/p/simplescan
What steps will reproduce the problem?
1. Run app without the barcode scanner installed
2. Attempt a scan
3.
What is the expected output? What do you see instead?
Expect a message saying scanner not installed. Usual practice is then to offer
to install it.
What version of the product are you using? On what operating system?
V0.31
Target was Nexus One Android 2.2.2
Please provide any additional information below.
Here's a fix. In SimpleScanActivity.java change the OnClickListener method,
then add the isIntentAvailable() method as follows:
/**
* A call-back for when the user presses the back button.
*/
OnClickListener mScanListener = new OnClickListener() {
public void onClick(View v) {
Intent intent = new Intent("com.google.zxing.client.android.SCAN");
intent.putExtra("com.google.zxing.client.android.SCAN.SCAN_MODE","ONE_D_MODE");
if (isIntentAvailable(SimpleScanActivity.this, "com.google.zxing.client.android.SCAN")) {
startActivityForResult(intent, 0);
} else {
Dialog confirmScannerInstall = new AlertDialog.Builder( SimpleScanActivity.this )
.setIcon( R.drawable.icon )
.setTitle( getString( R.string.app_name ) )
.setMessage( "The Barcode reader is not present - install it now?")
.setPositiveButton( "Yes", new DialogInterface.OnClickListener() {
public void onClick( DialogInterface dialog, int whichButton ) {
Uri uri = Uri.parse("market://search?q=pname:com.google.zxing.client.android");
Intent installIntent = new Intent(Intent.ACTION_VIEW, uri);
startActivity(installIntent);
}
})
.setNeutralButton("No" , new DialogInterface.OnClickListener() {
public void onClick( DialogInterface dialog, int whichButton ) {
return;
}
})
.create();
confirmScannerInstall.show();
}
}
};
public static boolean isIntentAvailable(Context context, String action) {
final PackageManager packageManager = context.getPackageManager();
final Intent intent = new Intent(action);
List<ResolveInfo> list =
packageManager.queryIntentActivities(intent,
PackageManager.MATCH_DEFAULT_ONLY);
return list.size() > 0;
}
Original issue reported on code.google.com by [email protected]
on 9 Feb 2011 at 2:50
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.