i got the following problem:
I am developing an app which requires the zxing-QR-Code reader to work properly. But how shall I know if it is installed?
I found some code which should fix the problem but wont work, so i figured I might ask wehere I found this code:
/**someQC**/
public void function() {
if(!isIntentAvailable(this, "com.google.zxing.client.android.SCAN")) {
intentNotAvaiable("com.google.zxing.client.android"); //handle no intent
}
/**somemoreQC to deal with the intent**/
private void intentNotAvaiable(String intentName) {
setContentView(R.layout.intentnotavailable);
TextView t = new TextView(this);
t = (TextView)findViewById(R.id.aint_available);
t.setText(intentName + "unbekannt, weiterleitung\n zum AndroidApp Market Place?");
gotoMarketPlace = ("market://search?q=pub:" + intentName);
}
public void goToMarketPlace(View view) { //this is the Button handler
Intent promptInstall = new Intent(Intent.ACTION_SEARCH).setPackage("com.android.vending").putExtra("query", gotoMarketPlace);
startActivity(promptInstall);
}
So the actual problem is, that when i try to start the marketplace (via a yes button) the app just crashes!
Use the
IntentIntegratorclass supplied by ZXing to kick off your scans, and it will detect the missing Barcode Scanner application and will lead the user to download it. Or, examine the source code toIntentIntegratorand apply its techniques.