List of usage examples for android.content Intent FLAG_ACTIVITY_CLEAR_TOP
int FLAG_ACTIVITY_CLEAR_TOP
To view the source code for android.content Intent FLAG_ACTIVITY_CLEAR_TOP.
Click Source Link
From source file:com.andrewshu.android.reddit.comments.CommentsListActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { if (!mCanChord) { // The user has already fired a shortcut with this hold down of the // menu key. return false; }/*from w w w . ja v a2 s. com*/ switch (item.getItemId()) { case R.id.op_menu_id: if (getOpThingInfo() == null) break; mVoteTargetThing = getOpThingInfo(); mReplyTargetName = getOpThingInfo().getName(); showDialog(Constants.DIALOG_COMMENT_CLICK); break; case R.id.op_subreddit_menu_id: Intent intent = new Intent(getApplicationContext(), ThreadsListActivity.class); intent.setData(Util.createSubredditUri(mSubreddit)); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(intent); Util.overridePendingTransition(mActivity_overridePendingTransition, this, android.R.anim.slide_in_left, android.R.anim.slide_out_right); break; case R.id.login_menu_id: showDialog(Constants.DIALOG_LOGIN); break; case R.id.logout_menu_id: Common.doLogout(mSettings, mClient, getApplicationContext()); Toast.makeText(this, "You have been logged out.", Toast.LENGTH_SHORT).show(); getNewDownloadCommentsTask().execute(Constants.DEFAULT_COMMENT_DOWNLOAD_LIMIT); break; case R.id.find_next_menu_id: if (last_search_string != null && last_search_string.length() > 0) findCommentText(last_search_string, true, true); break; case R.id.find_base_id: // This case is needed because the "default" case throws // an error, otherwise precluding anonymous "parent" menu items break; case R.id.find_menu_id: showDialog(Constants.DIALOG_FIND); break; case R.id.refresh_menu_id: CacheInfo.invalidateCachedThread(getApplicationContext()); getNewDownloadCommentsTask().execute(Constants.DEFAULT_COMMENT_DOWNLOAD_LIMIT); break; case R.id.sort_by_menu_id: showDialog(Constants.DIALOG_SORT_BY); break; case R.id.open_browser_menu_id: String url = new StringBuilder(Constants.REDDIT_BASE_URL + "/r/").append(mSubreddit) .append("/comments/").append(mThreadId).toString(); Common.launchBrowser(this, url, url, false, true, true, false); break; case R.id.op_delete_menu_id: mReplyTargetName = getOpThingInfo().getName(); mDeleteTargetKind = Constants.THREAD_KIND; showDialog(Constants.DIALOG_DELETE); break; case R.id.op_edit_menu_id: mReplyTargetName = getOpThingInfo().getName(); mEditTargetBody = getOpThingInfo().getSelftext(); showDialog(Constants.DIALOG_EDIT); break; case R.id.light_dark_menu_id: mSettings.setTheme(Util.getInvertedTheme(mSettings.getTheme())); relaunchActivity(); break; case R.id.inbox_menu_id: Intent inboxIntent = new Intent(getApplicationContext(), InboxActivity.class); startActivity(inboxIntent); break; case R.id.user_profile_menu_id: Intent profileIntent = new Intent(getApplicationContext(), ProfileActivity.class); startActivity(profileIntent); break; case R.id.preferences_menu_id: Intent prefsIntent = new Intent(getApplicationContext(), RedditPreferencesPage.class); startActivity(prefsIntent); break; case android.R.id.home: Common.goHome(this); break; default: throw new IllegalArgumentException("Unexpected action value " + item.getItemId()); } return true; }
From source file:RhodesService.java
@Override public void startActivity(Intent intent) { RhodesActivity ra = RhodesActivity.getInstance(); if (intent.getComponent() != null && intent.getComponent().compareTo(new ComponentName(this, RhodesActivity.class.getName())) == 0) { Logger.T(TAG, "Start or bring main activity: " + RhodesActivity.class.getName() + "."); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); if (ra == null) { intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); super.startActivity(intent); return; }//from w ww .j av a 2 s.c om } if (ra != null) { Logger.T(TAG, "Starting new activity on top."); if (DEBUG) { Bundle extras = intent.getExtras(); if (extras != null) { for (String key : extras.keySet()) { Object val = extras.get(key); if (val != null) Log.d(TAG, key + ": " + val.toString()); else Log.d(TAG, key + ": <empty>"); } } } ra.startActivity(intent); } else { throw new IllegalStateException( "Trying to start activity, but there is no main activity instance (we are in background, no UI active)"); } }
From source file:com.aimfire.gallery.GalleryActivity.java
private void switchThumbView() { /*//from w w w . j a v a2 s.c o m * note we use FLAG_ACTIVITY_CLEAR_TOP below which means if we came * here from Camera/CamcorderActivity, then they will be destroyed * once we return to main. this currently won't happen as we always * go from Camera/Camcorder to Photo/MovieActivity directly, without * going through gallery, but in the future if we do that, we will * need to revisit below */ Intent intent = new Intent(this, MainActivity.class); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK); intent.putExtra(MainConsts.EXTRA_MSG, mIsMyMedia); startActivity(intent); }
From source file:com.example.carsharing.CommuteActivity.java
@Override public boolean onKeyDown(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_BACK) { Intent returnp = new Intent(CommuteActivity.this, PersonalCenterActivity.class); returnp.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(returnp);/*from w w w . j av a 2 s .com*/ return false; } else { return super.onKeyDown(keyCode, event); } }
From source file:com.owncloud.android.authentication.AuthenticatorActivity.java
public void Reguser(View view) { String passwordva2 = mPasswordInput2.getText().toString().trim(); String passwordva1 = mPasswordInput.getText().toString().trim(); final String username = mUsernameInput.getText().toString().trim(); String loc = locationSpinner.getSelectedItem().toString(); locationSpinner.setOnItemSelectedListener(this); final String str1 = mHostUrlInput.getText().toString(); if (passwordva1.equals("") || passwordva2.equals("") || username.equals("")) { Toast.makeText(getApplicationContext(), "One or more of required fields not entered", Toast.LENGTH_SHORT).show(); } else if (!passwordva1.equals(passwordva2)) { mPasswordInput.setText(""); mPasswordInput2.setText(""); Toast.makeText(getApplicationContext(), "The two passwords do not match. Please reenter the passwords", Toast.LENGTH_LONG).show(); } else {//from w ww. ja v a 2 s. c o m //username = username + "@" + loc; final ArrayList<NameValuePair> params = new ArrayList<NameValuePair>(); params.add(new BasicNameValuePair("regname", username)); params.add(new BasicNameValuePair("regpass1", passwordva1)); params.add(new BasicNameValuePair("regpass2", passwordva2)); // Log.d("sdn object ",params.toString()); Log.d("new server ", str1); Runnable runnable = new Runnable() { @Override public void run() { HttpPost post = new HttpPost("http://" + str1 + "/androiduserreg.php"); HttpEntity entity; try { entity = new UrlEncodedFormEntity(params, "utf-8"); HttpClient client = new DefaultHttpClient(); post.setEntity(entity); client.getParams().setParameter(CoreProtocolPNames.USER_AGENT, System.getProperty("http.agent")); post.setHeader("User-Agent", "Android-ownCloud"); HttpResponse response = client.execute(post); if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) { HttpEntity entityresponse = response.getEntity(); String jsonentity = EntityUtils.toString(entityresponse); final JSONObject jsonObject = new JSONObject(jsonentity); String registerUserReply = jsonObject.getString("reply"); if (registerUserReply.equals(REGISTER_USER_SUCCESS)) { final String location_returned = jsonObject.getString("location"); runOnUiThread(new Runnable() { public void run() { if (!location_returned.equals(location)) { Log.d("location returned ", location_returned); Toast.makeText(getApplicationContext(), "Account created and your login id is " + location_returned, Toast.LENGTH_LONG).show(); } } }); Intent i = getBaseContext().getPackageManager() .getLaunchIntentForPackage(getBaseContext().getPackageName()); i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(i); } else if (registerUserReply.equals(REGISTER_USER_ALREADY_EXISTS)) { runOnUiThread(new Runnable() { public void run() { Toast.makeText(getApplicationContext(), "Username already exists on the server, try a different one", Toast.LENGTH_SHORT).show(); } }); } else { runOnUiThread(new Runnable() { public void run() { Toast.makeText(getApplicationContext(), "Unable to create account, please try after sometime", Toast.LENGTH_SHORT).show(); } }); } } } catch (UnsupportedEncodingException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } catch (JSONException e) { e.printStackTrace(); } } }; new Thread(runnable).start(); } }
From source file:com.wso2.mobile.mdm.services.Operation.java
/** * Issues a notification to inform the user that server has sent a message. *//*from ww w .ja v a2s.com*/ private static void generateNotification(Context context, String message) { int icon = R.drawable.ic_stat_gcm; long when = System.currentTimeMillis(); NotificationManager notificationManager = (NotificationManager) context .getSystemService(Context.NOTIFICATION_SERVICE); Notification notification = new Notification(icon, message, when); String title = context.getString(R.string.app_name); Intent notificationIntent = new Intent(context, NotifyActivity.class); notificationIntent.putExtra("notification", message); // set intent so it does not start a new activity notificationIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP); PendingIntent intent = PendingIntent.getActivity(context, 0, notificationIntent, 0); notification.setLatestEventInfo(context, title, message, intent); notification.flags |= Notification.FLAG_SHOW_LIGHTS; notificationManager.notify(0, notification); Toast.makeText(context, message, Toast.LENGTH_LONG).show(); }
From source file:com.android.gallery3d.app.PhotoPage.java
@Override /// M: [BUG.MODIFY] @{ /* public void onSingleTapUp(int x, int y) {*/ public void onSingleTapConfirmed(int x, int y) { Log.i(TAG, "<onSingleTapConfirmed>"); /// @}/*from w ww . j a v a 2 s. c om*/ if (mAppBridge != null) { if (mAppBridge.onSingleTapUp(x, y)) return; } MediaItem item = mModel.getMediaItem(0); if (item == null || item == mScreenNailItem) { // item is not ready or it is camera preview, ignore return; } int supported = item.getSupportedOperations(); /// M: [BUG.MARK] play video in onSingleTapUp @{ /* boolean playVideo = ((supported & MediaItem.SUPPORT_PLAY) != 0); */ /// @} boolean unlock = ((supported & MediaItem.SUPPORT_UNLOCK) != 0); boolean goBack = ((supported & MediaItem.SUPPORT_BACK) != 0); boolean launchCamera = ((supported & MediaItem.SUPPORT_CAMERA_SHORTCUT) != 0); /// M: [BEHAVIOR.ADD] [Camera independent from Gallery] @{ // Play video from secure camera, go into key guard. if (mPlaySecureVideo) { unlock = true; } /// @} /// M: [BUG.MARK] play video in onSingleTapUp @{ /* if (playVideo) { // determine if the point is at center (1/6) of the photo view. // (The position of the "play" icon is at center (1/6) of the photo) int w = mPhotoView.getWidth(); int h = mPhotoView.getHeight(); playVideo = (Math.abs(x - w / 2) * 12 <= w) && (Math.abs(y - h / 2) * 12 <= h); } if (playVideo) { if (mSecureAlbum == null) { playVideo(mActivity, item.getPlayUri(), item.getName()); } else { mActivity.getStateManager().finishState(this); } } else */ /// @} if (goBack) { /// M: [BUG.ADD] [Camera independent from Gallery] @{ // Don't need show bars when back to camera preview onActionBarAllowed(false); /// @} onBackPressed(); } else if (unlock) { /// M: [BEHAVIOR.ADD] [Camera independent from Gallery] @{ mPlaySecureVideo = false; /// @} Intent intent = new Intent(mActivity, GalleryActivity.class); /// M: [BUG.ADD] secure camera come here, use new task @{ intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK); /// @} /// M: [BUG.MARK] @{ // In secure camera, user can not skip key guard /*intent.putExtra(GalleryActivity.KEY_DISMISS_KEYGUARD, true);*/ /// @} mActivity.startActivity(intent); } else if (launchCamera) { launchCamera(); } else { /// M: [BUG.MODIFY] @{ /*toggleBars();*/ // if we are starting video player, give up toggleBars() to avoid view junk if (!mIsStartingVideoPlayer) { toggleBars(); } /// @} } }
From source file:mp.teardrop.PlaybackService.java
/** * Execute the given action./*from w w w. j av a 2 s .co m*/ * * @param action The action to execute. * @param receiver Optional. If non-null, update the PlaybackActivity with * new song or state from the executed action. The activity will still be * updated by the broadcast if not passed here; passing it just makes the * update immediate. */ public void performAction(Action action, PlaybackActivity receiver) { switch (action) { case Nothing: break; case Library: Intent intent = new Intent(this, LibraryActivity.class); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(intent); break; case PlayPause: { int state = playPause(); if (receiver != null) receiver.setState(state); break; } case NextSong: { Song song = shiftCurrentSong(SongTimeline.SHIFT_NEXT_SONG); if (receiver != null) receiver.setSong(song); break; } case PreviousSong: { Song song = shiftCurrentSong(SongTimeline.SHIFT_PREVIOUS_SONG); if (receiver != null) receiver.setSong(song); break; } case NextAlbum: { Song song = shiftCurrentSong(SongTimeline.SHIFT_NEXT_ALBUM); if (receiver != null) receiver.setSong(song); break; } case PreviousAlbum: { Song song = shiftCurrentSong(SongTimeline.SHIFT_PREVIOUS_ALBUM); if (receiver != null) receiver.setSong(song); break; } case Repeat: { int state = cycleFinishAction(); if (receiver != null) receiver.setState(state); break; } case Shuffle: { int state = cycleShuffle(); if (receiver != null) receiver.setState(state); break; } /* case EnqueueAlbum: //TODO: re-add these enqueueFromCurrent(MediaUtils.TYPE_ALBUM); break; case EnqueueArtist: enqueueFromCurrent(MediaUtils.TYPE_ARTIST); break; case EnqueueGenre: enqueueFromCurrent(MediaUtils.TYPE_GENRE); break; */ case ClearQueue: clearQueue(); Toast.makeText(this, R.string.queue_cleared, Toast.LENGTH_SHORT).show(); break; case ToggleControls: // Handled in FullPlaybackActivity.performAction break; default: throw new IllegalArgumentException("Invalid action: " + action); } }
From source file:com.android.mms.transaction.MessagingNotification.java
/** * Return the intent of multi-unread messges notification. *//*w ww. jav a 2 s .c o m*/ public static Intent getMultiThreadsViewIntent(Context context) { Intent intent; if (MessageUtils.isMailboxMode()) { intent = new Intent(context, MailBoxMessageList.class); intent.putExtra(MessageUtils.MAIL_BOX_ID, MailBoxMessageList.TYPE_INBOX); } else { intent = new Intent(context, ConversationList.class); } intent.setFlags( Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_CLEAR_TOP); return intent; }
From source file:com.mobiletin.inputmethod.indic.LatinIME.java
private void launchSettings() { mInputLogic.commitTyped(mSettings.getCurrent(), LastComposedWord.NOT_A_SEPARATOR); requestHideSelf(0);/* w ww .j a v a2 s . c o m*/ final MainKeyboardView mainKeyboardView = mKeyboardSwitcher.getMainKeyboardView(); if (mainKeyboardView != null) { mainKeyboardView.closing(); } final Intent intent = new Intent(); intent.setClass(LatinIME.this, SettingsActivity.class); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED | Intent.FLAG_ACTIVITY_CLEAR_TOP); intent.putExtra(SettingsActivity.EXTRA_SHOW_HOME_AS_UP, false); startActivity(intent); }