Issue 336: set Intent flag to make sure task's launched activities don't stay on top when returning to BS. Doing this for all Intents for now

git-svn-id: https://zxing.googlecode.com/svn/trunk@1230 59b500cc-1b3d-0410-9834-0bbf25fbcc57
This commit is contained in:
srowen 2010-03-01 15:19:45 +00:00
parent fa82c20c2f
commit f30410ff78
9 changed files with 27 additions and 6 deletions

View file

@ -151,6 +151,7 @@ public final class CaptureActivity extends Activity implements SurfaceHolder.Cal
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialogInterface, int i) {
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(getString(R.string.zxing_url)));
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
startActivity(intent);
}
};
@ -333,6 +334,7 @@ public final class CaptureActivity extends Activity implements SurfaceHolder.Cal
switch (item.getItemId()) {
case SHARE_ID: {
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
intent.setClassName(this, ShareActivity.class.getName());
startActivity(intent);
break;
@ -344,12 +346,14 @@ public final class CaptureActivity extends Activity implements SurfaceHolder.Cal
}
case SETTINGS_ID: {
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
intent.setClassName(this, PreferencesActivity.class.getName());
startActivity(intent);
break;
}
case HELP_ID: {
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
intent.setClassName(this, HelpActivity.class.getName());
startActivity(intent);
break;
@ -524,6 +528,7 @@ public final class CaptureActivity extends Activity implements SurfaceHolder.Cal
// Hand back whatever action they requested - this can be changed to Intents.Scan.ACTION when
// the deprecated intent is retired.
Intent intent = new Intent(getIntent().getAction());
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
intent.putExtra(Intents.Scan.RESULT, rawResult.toString());
intent.putExtra(Intents.Scan.RESULT_FORMAT, rawResult.getBarcodeFormat().toString());
Message message = Message.obtain(handler, R.id.return_scan_result);
@ -557,6 +562,7 @@ public final class CaptureActivity extends Activity implements SurfaceHolder.Cal
if (currentVersion > lastVersion) {
prefs.edit().putInt(PreferencesActivity.KEY_HELP_VERSION_SHOWN, currentVersion).commit();
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
intent.setClassName(this, HelpActivity.class.getName());
startActivity(intent);
return true;

View file

@ -92,7 +92,9 @@ public final class CaptureActivityHandler extends Handler {
break;
case R.id.launch_product_query:
String url = (String) message.obj;
activity.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url)));
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
activity.startActivity(intent);
break;
}
}

View file

@ -60,7 +60,9 @@ public final class HelpActivity extends Activity {
private final DialogInterface.OnClickListener groupsListener = new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialogInterface, int i) {
HelpActivity.this.startActivity(new Intent(Intent.ACTION_VIEW, BUGGY_URI));
Intent intent = new Intent(Intent.ACTION_VIEW, BUGGY_URI);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
HelpActivity.this.startActivity(intent);
}
};

View file

@ -47,8 +47,9 @@ final class BrowseBookListener implements AdapterView.OnItemClickListener {
String readBookURI = "http://books.google." +
LocaleManager.getBookSearchCountryTLD() +
"/books?id=" + volumeId + "&pg=" + pageId + "&vq=" + query;
activity.startActivity(new Intent(Intent.ACTION_VIEW,
Uri.parse(readBookURI)));
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(readBookURI));
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
activity.startActivity(intent);
}
}
}

View file

@ -93,6 +93,7 @@ public final class HistoryManager {
} else if (i == dialogItems.length - 2) {
String history = buildHistory();
Intent intent = new Intent(Intent.ACTION_SEND, Uri.parse("mailto:"));
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
intent.putExtra(Intent.EXTRA_SUBJECT, res.getString(R.string.history_email_title));
intent.putExtra(Intent.EXTRA_TEXT, history);
intent.setType("text/plain");

View file

@ -339,6 +339,7 @@ public abstract class ResultHandler {
void launchIntent(Intent intent) {
if (intent != null) {
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
try {
activity.startActivity(intent);
} catch (ActivityNotFoundException e) {

View file

@ -49,6 +49,7 @@ public final class AppPickerActivity extends ListActivity {
if (position >= 0 && position < labelsPackages.size()) {
String url = "market://search?q=pname:" + labelsPackages.get(position)[1];
Intent intent = new Intent();
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
intent.putExtra(Browser.BookmarkColumns.URL, url);
setResult(RESULT_OK, intent);
} else {

View file

@ -70,6 +70,7 @@ public final class BookmarkPickerActivity extends ListActivity {
protected void onListItemClick(ListView l, View view, int position, long id) {
if (cursor.moveToPosition(position)) {
Intent intent = new Intent();
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
intent.putExtra(Browser.BookmarkColumns.TITLE, cursor.getString(TITLE_COLUMN));
intent.putExtra(Browser.BookmarkColumns.URL, cursor.getString(URL_COLUMN));
setResult(RESULT_OK, intent);

View file

@ -65,14 +65,16 @@ public final class ShareActivity extends Activity {
private final Button.OnClickListener contactListener = new Button.OnClickListener() {
public void onClick(View v) {
startActivityForResult(new Intent(Intent.ACTION_PICK, Contacts.People.CONTENT_URI),
PICK_CONTACT);
Intent intent = new Intent(Intent.ACTION_PICK, Contacts.People.CONTENT_URI);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
startActivityForResult(intent, PICK_CONTACT);
}
};
private final Button.OnClickListener bookmarkListener = new Button.OnClickListener() {
public void onClick(View v) {
Intent intent = new Intent(Intent.ACTION_PICK);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
intent.setClassName(ShareActivity.this, BookmarkPickerActivity.class.getName());
startActivityForResult(intent, PICK_BOOKMARK);
}
@ -81,6 +83,7 @@ public final class ShareActivity extends Activity {
private final Button.OnClickListener appListener = new Button.OnClickListener() {
public void onClick(View v) {
Intent intent = new Intent(Intent.ACTION_PICK);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
intent.setClassName(ShareActivity.this, AppPickerActivity.class.getName());
startActivityForResult(intent, PICK_APP);
}
@ -92,6 +95,7 @@ public final class ShareActivity extends Activity {
// Should always be true, because we grey out the clipboard button in onResume() if it's empty
if (clipboard.hasText()) {
Intent intent = new Intent(Intents.Encode.ACTION);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
intent.putExtra(Intents.Encode.TYPE, Contents.Type.TEXT);
intent.putExtra(Intents.Encode.DATA, clipboard.getText());
intent.putExtra(Intents.Encode.FORMAT, Contents.Format.QR_CODE);
@ -144,6 +148,7 @@ public final class ShareActivity extends Activity {
private void showTextAsBarcode(String text) {
Intent intent = new Intent(Intents.Encode.ACTION);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
intent.putExtra(Intents.Encode.TYPE, Contents.Type.TEXT);
intent.putExtra(Intents.Encode.DATA, text);
intent.putExtra(Intents.Encode.FORMAT, Contents.Format.QR_CODE);
@ -212,6 +217,7 @@ public final class ShareActivity extends Activity {
}
Intent intent = new Intent(Intents.Encode.ACTION);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
intent.putExtra(Intents.Encode.TYPE, Contents.Type.CONTACT);
intent.putExtra(Intents.Encode.DATA, bundle);
intent.putExtra(Intents.Encode.FORMAT, Contents.Format.QR_CODE);