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.medisa.myspacecal.Range.java
private void invokeActivity(String title, int resId) { Intent intent = new Intent(this, MainActivity.class); intent.putExtra(EXTRA_TITLE, title); intent.putExtra(EXTRA_RESOURCE_ID, resId); intent.putExtra(EXTRA_MODE, sideNavigationView.getMode() == Mode.LEFT ? 0 : 1); // all of the other activities on top of it will be closed and this // Intent will be delivered to the (now on top) old activity as a // new Intent. intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(intent);/*from ww w . j av a 2 s. co m*/ // no animation of transition overridePendingTransition(0, 0); }
From source file:ca.mymenuapp.ui.activities.MainActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { // Pass the event to ActionBarDrawerToggle, if it returns // true, then it has handled the app icon touch event if (drawerToggle.onOptionsItemSelected(item)) { return true; }/*from w ww .j a v a2 s . c o m*/ // Handle other action bar items... switch (item.getItemId()) { case R.id.logout: userPreference.delete(); Intent logoutIntent = new Intent(this, LoginActivity.class); logoutIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(logoutIntent); finish(); return true; case R.id.login: userPreference.delete(); Intent loginIntent = new Intent(this, LoginActivity.class); loginIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(loginIntent); finish(); return true; default: return super.onOptionsItemSelected(item); } }
From source file:com.msted.lensrocket.LensRocketService.java
public void logout(boolean shouldRedirectToLogin) { //Clear values mFriendNames.clear();/*from ww w .j a v a 2s. c om*/ mFriends.clear(); mRockets.clear(); //Clear the cookies so they won't auto login to a provider again CookieSyncManager.createInstance(mContext); CookieManager cookieManager = CookieManager.getInstance(); cookieManager.removeAllCookie(); //Clear the user id and token from the shared preferences SharedPreferences settings = mContext.getSharedPreferences("UserData", 0); SharedPreferences.Editor preferencesEditor = settings.edit(); preferencesEditor.clear(); preferencesEditor.commit(); //Clear settings shared preferences SharedPreferences settingsPrefs = PreferenceManager.getDefaultSharedPreferences(mContext); if (settingsPrefs != null) { preferencesEditor = settingsPrefs.edit(); preferencesEditor.clear(); preferencesEditor.commit(); } mClient.logout(); //Take the user back to the splash screen activity to relogin if requested if (shouldRedirectToLogin) { Intent logoutIntent = new Intent(mContext, SplashScreenActivity.class); logoutIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK); mContext.startActivity(logoutIntent); } }
From source file:org.sirimangalo.meditationplus.ActivityMain.java
@Override protected void onResume() { super.onResume(); isShowing = true;//from w w w . jav a 2s . co m listVersion = -1; chatVersion = -1; restartTimer = true; refreshPeriod = Integer.parseInt(prefs.getString("refresh_period", "10")) * 1000; refreshPeriod = Math.max(refreshPeriod, 10); fullRefreshPeriod = Integer.parseInt(prefs.getString("full_refresh_period", "60")) * 1000; fullRefreshPeriod = Math.max(fullRefreshPeriod, 60); if (ct != null) ct.cancel(); ct = new CountDownTimer(fullRefreshPeriod, refreshPeriod) { @Override public void onTick(long l) { ArrayList<NameValuePair> nvp = new ArrayList<NameValuePair>(); if (l < fullRefreshPeriod - refreshPeriod && isShowing) { doSubmit(null, nvp, false); } } @Override public void onFinish() { if (isShowing) { listVersion = -1; chatVersion = -1; restartTimer = true; ArrayList<NameValuePair> nvp = new ArrayList<NameValuePair>(); nvp.add(new BasicNameValuePair("full_update", "true")); doSubmit(null, nvp, false); } } }; loginToken = prefs.getString("login_token", ""); if (loginToken.equals("")) { Intent i = new Intent(this, ActivityMain.class); i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); if (!doingLogin) startActivity(i); } else { username = prefs.getString("username", ""); password = ""; doSubmit(null, new ArrayList<NameValuePair>(), false); } }
From source file:com.jeremyhaberman.playgrounds.WebPlaygroundDAO.java
@Override public Collection<? extends Playground> getWithin(Context context, GeoPoint topLeft, GeoPoint bottomRight, int maxQuantity) { playgrounds = new ArrayList<Playground>(); String result = swingset.getResources().getString(R.string.error); HttpURLConnection httpConnection = null; Log.d(TAG, "getPlaygrounds()"); try {/*from w ww. j a v a 2s . c om*/ // Check if task has been interrupted if (Thread.interrupted()) { throw new InterruptedException(); } // Build query URL url = new URL("http://swingsetweb.appspot.com/playground?" + TYPE_PARAM + "=" + WITHIN + "&" + TOP_LEFT_LATITUDE_PARAM + "=" + topLeft.getLatitudeE6() / 1E6 + "&" + TOP_LEFT_LONGITUDE_PARAM + "=" + topLeft.getLongitudeE6() / 1E6 + "&" + BOTTOM_RIGHT_LATITUDE_PARAM + "=" + bottomRight.getLatitudeE6() / 1E6 + "&" + BOTTOM_RIGHT_LONGITUDE_PARAM + "=" + bottomRight.getLongitudeE6() / 1E6); httpConnection = (HttpURLConnection) url.openConnection(); httpConnection.setConnectTimeout(15000); httpConnection.setReadTimeout(15000); StringBuilder response = new StringBuilder(); if (httpConnection.getResponseCode() == HttpURLConnection.HTTP_OK) { // Read results from the query BufferedReader input = new BufferedReader( new InputStreamReader(httpConnection.getInputStream(), "UTF-8")); String strLine = null; while ((strLine = input.readLine()) != null) { response.append(strLine); } input.close(); } // Parse to get translated text JSONArray jsonPlaygrounds = new JSONArray(response.toString()); int numOfPlaygrounds = jsonPlaygrounds.length(); JSONObject jsonPlayground = null; for (int i = 0; i < numOfPlaygrounds; i++) { jsonPlayground = jsonPlaygrounds.getJSONObject(i); playgrounds.add(toPlayground(jsonPlayground)); } } catch (Exception e) { Log.e(TAG, "Exception", e); Intent errorIntent = new Intent(context, Playgrounds.class); errorIntent.putExtra("Exception", e.getLocalizedMessage()); errorIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); context.startActivity(errorIntent); } finally { if (httpConnection != null) { httpConnection.disconnect(); } } Log.d(TAG, " -> returned " + result); return playgrounds; }
From source file:com.andrew.apollo.ui.activities.ShortcutActivity.java
/** * Starts playback, open {@link AudioPlayerActivity} and finishes this one *//*from w ww . j a v a 2s . c om*/ private void allDone() { final boolean shouldOpenAudioPlayer = mIntent.getBooleanExtra(OPEN_AUDIO_PLAYER, true); // Play the list if (mList != null && mList.length > 0) { MusicUtils.playAll(this, mList, 0, mShouldShuffle); } // Open the now playing screen if (shouldOpenAudioPlayer) { final Intent intent = new Intent(this, AudioPlayerActivity.class); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(intent); } // All done finish(); }
From source file:com.ayuget.redface.ui.activity.BaseDrawerActivity.java
private void populateAccountList(List<User> users) { accountListContainer.removeAllViews(); LayoutInflater layoutInflater = LayoutInflater.from(this); for (User user : users) { addUserToAccountList(layoutInflater, user); }// ww w . ja v a2s. co m View addAccountView = layoutInflater.inflate(R.layout.navigation_drawer_add_account, accountListContainer, false); addAccountView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // Add account intent Intent intent = new Intent(BaseDrawerActivity.this, AccountActivity.class); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(intent); } }); accountListContainer.addView(addAccountView); }
From source file:com.android.yijiang.kzx.http.AsyncHttpResponseHandler.java
private void gotoLogin() { SharedPreferences sp = ApplicationController.getInstance().getSharedPreferences("token_info", 0); boolean isSuccess = sp.edit().clear().commit(); if (isSuccess) { JPushInterface.clearAllNotifications(ApplicationController.getInstance()); JPushInterface.stopPush(ApplicationController.getInstance()); Intent i = new Intent(ApplicationController.getInstance(), LoginActivity.class); i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK); ApplicationController.getInstance().startActivity(i); }/*w w w. jav a 2 s . co m*/ }
From source file:de.badaix.snapcast.MainActivity.java
private void startSnapclient() { if (TextUtils.isEmpty(host)) return;//w w w . j ava 2s . c o m Intent i = new Intent(this, SnapclientService.class); i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP); i.putExtra(SnapclientService.EXTRA_HOST, host); i.putExtra(SnapclientService.EXTRA_PORT, port); i.setAction(SnapclientService.ACTION_START); startService(i); }
From source file:com.inloc.dr.StepService.java
/** * Show a notification while this service is running. */// w w w. j a va 2 s. c o m private void showNotification() { CharSequence text = getText(R.string.app_name); Notification notification = new Notification(R.drawable.ic_notification, null, System.currentTimeMillis()); notification.flags = Notification.FLAG_NO_CLEAR | Notification.FLAG_ONGOING_EVENT; Intent pedometerIntent = new Intent(); pedometerIntent.setComponent(new ComponentName(this, DeadReckoning.class)); pedometerIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); PendingIntent contentIntent = PendingIntent.getActivity(this, 0, pedometerIntent, 0); notification.setLatestEventInfo(this, text, getText(R.string.notification_subtitle), contentIntent); mNM.notify(R.string.app_name, notification); }