List of usage examples for android.content Intent FLAG_ACTIVITY_CLEAR_TASK
int FLAG_ACTIVITY_CLEAR_TASK
To view the source code for android.content Intent FLAG_ACTIVITY_CLEAR_TASK.
Click Source Link
From source file:com.shopify.sample.activity.CheckoutActivity.java
private void launchBrowser(String url) { Intent intent = new Intent(Intent.ACTION_VIEW); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK); intent.setData(Uri.parse(url));// w w w . j a v a2 s. c om try { intent.setPackage("com.android.chrome"); startActivity(intent); } catch (Exception launchChromeException) { try { // Chrome could not be opened, attempt to us other launcher intent.setPackage(null); startActivity(intent); } catch (Exception launchOtherException) { onError(getString(R.string.checkout_error)); } } }
From source file:edu.stanford.mobisocial.dungbeetle.ui.MusubiBaseActivity.java
/** * Go back to the home activity.//from ww w .j a v a 2 s . c om * * @param context Context * @return void */ public void goHome(Context context) { final Intent intent = new Intent(context, HomeActivity.class); if (Build.VERSION.SDK_INT < 11) intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); else intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK); context.startActivity(intent); }
From source file:mobisocial.musubi.ui.MusubiBaseActivity.java
/** * Go back to the home activity.//from ww w. j a v a 2 s. c o m * * @param context Context * @return void */ private void goHome() { final Intent intent = new Intent(this, FeedListActivity.class); if (Build.VERSION.SDK_INT < 11) { intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); } else { intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK); } startActivity(intent); }
From source file:de.schildbach.wallet.service.InactivityNotificationService.java
private void handleDonate() { final Coin balance = wallet.getBalance(BalanceType.AVAILABLE_SPENDABLE); SendCoinsActivity.startDonate(this, balance, FeeCategory.ECONOMIC, Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK); nm.cancel(Constants.NOTIFICATION_ID_INACTIVITY); sendBroadcast(new Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS)); }
From source file:foo.fruitfox.evend.LoginActivity.java
public void login(View view) { Intent intent = new Intent(this, WelcomeActivity.class); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(intent);/*from w ww . ja v a 2 s . c om*/ finish(); }
From source file:com.oakesville.mythling.MediaListActivity.java
@Override public void sort() throws IOException, JSONException, ParseException { super.refresh(); getAppSettings().setLastLoad(0);/*w w w . j a v a 2 s .com*/ SortType sortType = getAppSettings().getMediaSettings().getSortType(); if (getMediaType() == MediaType.recordings && (sortType == SortType.byDate || sortType == SortType.byRating)) setPath(""); // recordings list will be flattened Uri uri = new Uri.Builder().path(getPath()).build(); Intent intent = new Intent(Intent.ACTION_VIEW, uri, this, MainActivity.class); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(intent); finish(); }
From source file:org.gateshipone.malp.application.background.NotificationManager.java
public synchronized void updateNotification(MPDTrack track, MPDCurrentStatus.MPD_PLAYBACK_STATE state) { if (track != null) { mNotificationBuilder = new NotificationCompat.Builder(mService); // Open application intent Intent contentIntent = new Intent(mService, MainActivity.class); contentIntent.putExtra(MainActivity.MAINACTIVITY_INTENT_EXTRA_REQUESTEDVIEW, MainActivity.MAINACTIVITY_INTENT_EXTRA_REQUESTEDVIEW_NOWPLAYINGVIEW); contentIntent.addFlags(/* w w w . ja v a 2 s. c om*/ Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_NO_ANIMATION | Intent.FLAG_ACTIVITY_NO_HISTORY); PendingIntent contentPendingIntent = PendingIntent.getActivity(mService, INTENT_OPENGUI, contentIntent, PendingIntent.FLAG_UPDATE_CURRENT); mNotificationBuilder.setContentIntent(contentPendingIntent); // Set pendingintents // Previous song action Intent prevIntent = new Intent(BackgroundService.ACTION_PREVIOUS); PendingIntent prevPendingIntent = PendingIntent.getBroadcast(mService, INTENT_PREVIOUS, prevIntent, PendingIntent.FLAG_UPDATE_CURRENT); NotificationCompat.Action prevAction = new NotificationCompat.Action.Builder( R.drawable.ic_skip_previous_48dp, "Previous", prevPendingIntent).build(); // Pause/Play action PendingIntent playPauseIntent; int playPauseIcon; if (state == MPDCurrentStatus.MPD_PLAYBACK_STATE.MPD_PLAYING) { Intent pauseIntent = new Intent(BackgroundService.ACTION_PAUSE); playPauseIntent = PendingIntent.getBroadcast(mService, INTENT_PLAYPAUSE, pauseIntent, PendingIntent.FLAG_UPDATE_CURRENT); playPauseIcon = R.drawable.ic_pause_48dp; } else { Intent playIntent = new Intent(BackgroundService.ACTION_PLAY); playPauseIntent = PendingIntent.getBroadcast(mService, INTENT_PLAYPAUSE, playIntent, PendingIntent.FLAG_UPDATE_CURRENT); playPauseIcon = R.drawable.ic_play_arrow_48dp; } NotificationCompat.Action playPauseAction = new NotificationCompat.Action.Builder(playPauseIcon, "PlayPause", playPauseIntent).build(); // Stop action Intent stopIntent = new Intent(BackgroundService.ACTION_STOP); PendingIntent stopPendingIntent = PendingIntent.getBroadcast(mService, INTENT_STOP, stopIntent, PendingIntent.FLAG_UPDATE_CURRENT); NotificationCompat.Action stopActon = new NotificationCompat.Action.Builder( R.drawable.ic_stop_black_48dp, "Stop", stopPendingIntent).build(); // Next song action Intent nextIntent = new Intent(BackgroundService.ACTION_NEXT); PendingIntent nextPendingIntent = PendingIntent.getBroadcast(mService, INTENT_NEXT, nextIntent, PendingIntent.FLAG_UPDATE_CURRENT); NotificationCompat.Action nextAction = new NotificationCompat.Action.Builder( R.drawable.ic_skip_next_48dp, "Next", nextPendingIntent).build(); // Quit action Intent quitIntent = new Intent(BackgroundService.ACTION_QUIT_BACKGROUND_SERVICE); PendingIntent quitPendingIntent = PendingIntent.getBroadcast(mService, INTENT_QUIT, quitIntent, PendingIntent.FLAG_UPDATE_CURRENT); mNotificationBuilder.setDeleteIntent(quitPendingIntent); mNotificationBuilder.setVisibility(NotificationCompat.VISIBILITY_PUBLIC); mNotificationBuilder.setSmallIcon(R.drawable.ic_notification_24dp); mNotificationBuilder.addAction(prevAction); mNotificationBuilder.addAction(playPauseAction); mNotificationBuilder.addAction(stopActon); mNotificationBuilder.addAction(nextAction); NotificationCompat.MediaStyle notificationStyle = new NotificationCompat.MediaStyle(); notificationStyle.setShowActionsInCompactView(1, 2); mNotificationBuilder.setStyle(notificationStyle); String title; if (track.getTrackTitle().isEmpty()) { title = FormatHelper.getFilenameFromPath(track.getPath()); } else { title = track.getTrackTitle(); } mNotificationBuilder.setContentTitle(title); String secondRow; if (!track.getTrackArtist().isEmpty() && !track.getTrackAlbum().isEmpty()) { secondRow = track.getTrackArtist() + mService.getString(R.string.track_item_separator) + track.getTrackAlbum(); } else if (track.getTrackArtist().isEmpty() && !track.getTrackAlbum().isEmpty()) { secondRow = track.getTrackAlbum(); } else if (track.getTrackAlbum().isEmpty() && !track.getTrackArtist().isEmpty()) { secondRow = track.getTrackArtist(); } else { secondRow = track.getPath(); } // Set the media session metadata updateMetadata(track, state); mNotificationBuilder.setContentText(secondRow); // Remove unnecessary time info mNotificationBuilder.setWhen(0); // Cover but only if changed if (mNotification == null || !track.getTrackAlbum().equals(mLastTrack.getTrackAlbum())) { mLastTrack = track; mLastBitmap = null; mCoverLoader.getImage(mLastTrack, true); } // Only set image if an saved one is available if (mLastBitmap != null) { mNotificationBuilder.setLargeIcon(mLastBitmap); } else { /** * Create a dummy placeholder image for versions greater android 7 because it * does not automatically show the application icon anymore in mediastyle notifications. */ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { Drawable icon = mService.getDrawable(R.drawable.notification_placeholder_256dp); Bitmap iconBitmap = Bitmap.createBitmap(icon.getIntrinsicWidth(), icon.getIntrinsicHeight(), Bitmap.Config.ARGB_8888); Canvas canvas = new Canvas(iconBitmap); DrawFilter filter = new PaintFlagsDrawFilter(Paint.ANTI_ALIAS_FLAG, 1); canvas.setDrawFilter(filter); icon.setBounds(0, 0, canvas.getWidth(), canvas.getHeight()); icon.setFilterBitmap(true); icon.draw(canvas); mNotificationBuilder.setLargeIcon(iconBitmap); } else { /** * For older android versions set the null icon which will result in a dummy icon * generated from the application icon. */ mNotificationBuilder.setLargeIcon(null); } } // Build the notification mNotification = mNotificationBuilder.build(); // Send the notification away mNotificationManager.notify(NOTIFICATION_ID, mNotification); } }
From source file:com.ofalvai.bpinfo.ui.settings.SettingsActivity.java
@Override public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) { // Language/*from www . j a v a 2 s. co m*/ if (key.equals(getString(R.string.pref_key_language))) { String languageValue = sharedPreferences.getString(key, "default"); FabricUtils.logLanguageChange(languageValue); showLanguageRestartDialog(); } // Debug mode else if (key.equals(getString(R.string.pref_key_debug_mode))) { boolean state = mSharedPreferences.getBoolean(key, false); String text = state ? getString(R.string.debug_mode_on) : getString(R.string.debog_mode_off); Toast.makeText(this, text, Toast.LENGTH_LONG).show(); FabricUtils.logDebugMode(String.valueOf(state)); } // Data source else if (key.equals(getString(R.string.pref_key_data_source))) { Toast.makeText(this, R.string.data_source_changed_refreshed, Toast.LENGTH_SHORT).show(); FabricUtils.logDataSourceChange(mSharedPreferences.getString(key, "")); // Recreating AlertListActivity. This relies on BpInfoApplication's preference listener, // which can rebuild the Dagger dependency graph so that the new Activity (and its // Fragments' presenters) will use the new data source Intent intent = new Intent(this, AlertListActivity.class); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK); this.startActivity(intent); } }
From source file:org.messic.android.smartphone.activities.searchmessicservice.SearchMessicServiceActivity.java
private Subscription subscribe() { return RxDispatcher.get().subscribe(new RxDispatcher.RxSubscriber() { public void call(RxAction event) { if (event.isType(SearchMessicServiceEvents.EVENT_SHOW_SCREEN)) { String screen = (String) event.getSimpleData(); if (screen.equals(SearchMessicServiceEvents.SCREEN_MANUAL_SEARCH)) { Intent ssa = new Intent(SearchMessicServiceActivity.this, SearchManualMessicServiceActivity.class); SearchMessicServiceActivity.this.startActivity(ssa); } else if (screen.equals(SearchMessicServiceEvents.SCREEN_LOGINOFFLINE)) { Intent ssa = new Intent(SearchMessicServiceActivity.this, MainActivity.class); ssa.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK); SearchMessicServiceActivity.this.startActivity(ssa); }/*from ww w . ja v a 2 s . c o m*/ } } }); }
From source file:id.satusatudua.sigap.ui.fragment.SettingFragment.java
@Override public void onSuccessLogout() { Intent intent = new Intent(getActivity(), LoginActivity.class); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK); startActivity(intent);/*from w w w . ja v a 2s .c o m*/ }