- Intent i = new Intent("com.google.zxing.client.android.SCAN");
- i.putExtra("SCAN_MODE", "QR_CODE_MODE");
- i.putExtra("SAVE_HISTORY", false);
- startActivityForResult(i, 0);
- return false;
+ Intent i = new Intent(ACTION_SCAN);
+ i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
+ i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
+ i.addCategory(Intent.CATEGORY_DEFAULT);
+ i.putExtra("SCAN_MODE", "QR_CODE_MODE");
+ i.putExtra("SAVE_HISTORY", false);
+
+ String pkg = findAppPackage(i);
+ if (pkg != null) {
+ i.setPackage(pkg);
+ startActivityForResult(i, 0);
+ return false;
+ }
+
+ new AlertDialog.Builder(MainActivity.this)
+ .setTitle(R.string.install_title)
+ .setMessage(R.string.install_message)
+ .setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialogInterface, int i) {
+ Uri uri = Uri.parse("market://details?id=" + providers.get(0));
+ Intent intent = new Intent(Intent.ACTION_VIEW, uri);
+ try {
+ startActivity(intent);
+ } catch (ActivityNotFoundException e) {
+ e.printStackTrace();
+ }
+ }
+ })
+ .setNegativeButton(R.string.no, new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialogInterface, int i) {
+ return;
+ }
+ })
+ .create().show();
+
+ return false;