List of usage examples for android.content Intent FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS
int FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS
To view the source code for android.content Intent FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS.
Click Source Link
From source file:org.wso2.emm.agent.services.NotificationService.java
/** * This method is used to post a notification in the device. * * @param operationId id of the calling notification operation. * @param messageTitle message title to be displayed * @param messageText message text to be displayed *//* w w w . j av a2 s .co m*/ public void showNotification(int operationId, String messageTitle, String messageText) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { Intent notification = new Intent(context, NotificationReceiver.class); notification.putExtra(Constants.OPERATION_ID, operationId); PendingIntent dismiss = PendingIntent.getBroadcast(context, operationId, notification, PendingIntent.FLAG_ONE_SHOT); NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(context) .setSmallIcon(R.drawable.notification).setContentTitle(messageTitle).setContentText(messageText) .setPriority(android.app.Notification.PRIORITY_MAX) .setDefaults(android.app.Notification.DEFAULT_VIBRATE) .setDefaults(android.app.Notification.DEFAULT_SOUND) .setCategory(android.app.Notification.CATEGORY_CALL).setOngoing(true).setOnlyAlertOnce(true) .setTicker(context.getResources().getString(R.string.txt_notification)) .addAction(R.drawable.abs__ic_clear, "Dismiss", dismiss); notifyManager.notify(operationId, mBuilder.build()); } else { Intent intent = new Intent(context, AlertActivity.class); intent.putExtra(context.getResources().getString(R.string.intent_extra_message_title), messageTitle); intent.putExtra(context.getResources().getString(R.string.intent_extra_message_text), messageText); intent.putExtra(context.getResources().getString(R.string.intent_extra_operation_id), operationId); intent.putExtra(context.getResources().getString(R.string.intent_extra_type), context.getResources().getString(R.string.intent_extra_alert)); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS); context.startActivity(intent); } }
From source file:com.ivanmagda.inventory.ui.ProductEditor.java
@Override public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) { if (requestCode == PERMISSION_REQUEST_READ_EXTERNAL_STORAGE) { if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) { startPickImageIntent();/*from w w w . j a v a2s . c om*/ } else { Snackbar.make(findViewById(android.R.id.content), R.string.enable_persmission_from_settings, Snackbar.LENGTH_INDEFINITE).setAction(R.string.enable, new View.OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(); intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS); intent.addCategory(Intent.CATEGORY_DEFAULT); intent.setData(Uri.parse("package:" + getPackageName())); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY); intent.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS); startActivity(intent); } }).show(); } } }
From source file:org.wso2.iot.agent.services.NotificationService.java
/** * This method is used to post a notification in the device. * * @param operationId id of the calling notification operation. * @param messageTitle message title to be displayed * @param messageText message text to be displayed *//*w w w . j a v a 2 s .c om*/ public void showNotification(int operationId, String messageTitle, String messageText) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { Intent notification = new Intent(context, NotificationReceiver.class); notification.putExtra(Constants.OPERATION_ID, operationId); PendingIntent dismiss = PendingIntent.getBroadcast(context, operationId, notification, PendingIntent.FLAG_ONE_SHOT); NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(context) .setSmallIcon(R.drawable.ic_notifications_white_24dp).setContentTitle(messageTitle) .setContentText(messageText).setPriority(android.app.Notification.PRIORITY_MAX) .setDefaults(android.app.Notification.DEFAULT_VIBRATE) .setDefaults(android.app.Notification.DEFAULT_SOUND) .setCategory(android.app.Notification.CATEGORY_CALL).setOngoing(true).setOnlyAlertOnce(true) .setTicker(context.getResources().getString(R.string.txt_notification)) .addAction(R.drawable.dismiss, "Dismiss", dismiss); notifyManager.notify(operationId, mBuilder.build()); } else { Intent intent = new Intent(context, AlertActivity.class); intent.putExtra(context.getResources().getString(R.string.intent_extra_message_title), messageTitle); intent.putExtra(context.getResources().getString(R.string.intent_extra_message_text), messageText); intent.putExtra(context.getResources().getString(R.string.intent_extra_operation_id), operationId); intent.putExtra(context.getResources().getString(R.string.intent_extra_type), context.getResources().getString(R.string.intent_extra_alert)); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS); context.startActivity(intent); } }
From source file:com.battlelancer.seriesguide.appwidget.ListWidgetProvider.java
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH) public static RemoteViews buildRemoteViews(Context context, AppWidgetManager appWidgetManager, int appWidgetId) { // setup intent pointing to RemoteViewsService providing the views for the collection Intent intent = new Intent(context, ListWidgetService.class); intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId); // When intents are compared, the extras are ignored, so we need to // embed the extras into the data so that the extras will not be // ignored./*w w w . j ava 2 s. c om*/ intent.setData(Uri.parse(intent.toUri(Intent.URI_INTENT_SCHEME))); // determine layout (current size) and theme (user pref) final boolean isCompactLayout = isCompactLayout(appWidgetManager, appWidgetId); final boolean isLightTheme = WidgetSettings.isLightTheme(context, appWidgetId); int layoutResId; if (isLightTheme) { layoutResId = isCompactLayout ? R.layout.appwidget_v11_light_compact : R.layout.appwidget_v11_light; } else { layoutResId = isCompactLayout ? R.layout.appwidget_v11_compact : R.layout.appwidget_v11; } // build widget views RemoteViews rv = new RemoteViews(context.getPackageName(), layoutResId); rv.setRemoteAdapter(R.id.list_view, intent); // The empty view is displayed when the collection has no items. It // should be a sibling of the collection view. rv.setEmptyView(R.id.list_view, R.id.empty_view); // set the background color int bgColor = WidgetSettings.getWidgetBackgroundColor(context, appWidgetId, isLightTheme); rv.setInt(R.id.container, "setBackgroundColor", bgColor); // determine type specific values final int widgetType = WidgetSettings.getWidgetListType(context, appWidgetId); int showsTabIndex; int titleResId; int emptyResId; if (widgetType == WidgetSettings.Type.UPCOMING) { // upcoming showsTabIndex = ShowsActivity.InitBundle.INDEX_TAB_UPCOMING; titleResId = R.string.upcoming; emptyResId = R.string.noupcoming; } else if (widgetType == WidgetSettings.Type.RECENT) { // recent showsTabIndex = ShowsActivity.InitBundle.INDEX_TAB_RECENT; titleResId = R.string.recent; emptyResId = R.string.norecent; } else { // favorites showsTabIndex = ShowsActivity.InitBundle.INDEX_TAB_SHOWS; titleResId = R.string.action_shows_filter_favorites; emptyResId = R.string.no_nextepisode; } // change title and empty view based on type rv.setTextViewText(R.id.empty_view, context.getString(emptyResId)); if (!isCompactLayout) { // only regular layout has text title rv.setTextViewText(R.id.widgetTitle, context.getString(titleResId)); } // app launch button final Intent appLaunchIntent = new Intent(context, ShowsActivity.class) .putExtra(ShowsActivity.InitBundle.SELECTED_TAB, showsTabIndex); PendingIntent pendingIntent = TaskStackBuilder.create(context).addNextIntent(appLaunchIntent) .getPendingIntent(appWidgetId, PendingIntent.FLAG_UPDATE_CURRENT); rv.setOnClickPendingIntent(R.id.widget_title, pendingIntent); // item intent template, launches episode detail view TaskStackBuilder builder = TaskStackBuilder.create(context); builder.addNextIntent(appLaunchIntent); builder.addNextIntent(new Intent(context, EpisodesActivity.class)); rv.setPendingIntentTemplate(R.id.list_view, builder.getPendingIntent(1, PendingIntent.FLAG_UPDATE_CURRENT)); // settings button Intent settingsIntent = new Intent(context, ListWidgetConfigure.class) .addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS) .putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId); rv.setOnClickPendingIntent(R.id.widget_settings, PendingIntent.getActivity(context, appWidgetId, settingsIntent, PendingIntent.FLAG_UPDATE_CURRENT)); return rv; }
From source file:com.etalio.android.EtalioBase.java
/** * Redirects the end user to Etalio sign in. Sign in will happen through the * Etalio app if installed, else through the web browser. * * <code>mEtalio.initiateEtalioSignIn(this, "profile.basic.r profile.email.r");</code> * * @param activity the activity used to call Etalio sign in. * @param scope scopes for the sign in. The scopes should be separated by spaces, like "profile.basic.r profile.email.r" */// w w w .java2 s . co m public void initiateEtalioSignIn(Activity activity, String scope) { resetState(); if (!isEtalioInstalled(activity)) { activity.startActivity(new Intent(Intent.ACTION_VIEW, getSignInUrl(scope))); } else { Intent etalio = new Intent(); etalio.setClassName("com.etalio.android", "com.etalio.android.app.ui.activity.SingleSignOnActivity"); etalio.putExtra(EXTRA_CLIENT_ID, mClientId); etalio.putExtra(EXTRA_PACKAGE_NAME, activity.getPackageName()); etalio.setFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS); activity.startActivityForResult(etalio, REQUEST_CODE_SSO); } }
From source file:com.trail.octo.Identity.java
public void requestCameraPermission() { if (ContextCompat.checkSelfPermission(this, Manifest.permission.CAMERA) != PackageManager.PERMISSION_GRANTED) { // Should we show an explanation? if (ActivityCompat.shouldShowRequestPermissionRationale(this, Manifest.permission.CAMERA)) { Log.e("Check", "Go To Settings"); Toast.makeText(getApplicationContext(), "OCTO requires this Permission to upload Images!", Toast.LENGTH_LONG).show(); final Intent i = new Intent(); i.setAction(android.provider.Settings.ACTION_APPLICATION_DETAILS_SETTINGS); i.addCategory(Intent.CATEGORY_DEFAULT); i.setData(Uri.parse("package:" + Identity.this.getPackageName())); i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); i.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY); i.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS); startActivity(i);// Show an expanation to the user *asynchronously* -- don't block // this thread waiting for the user's response! After the user // sees the explanation, try again to request the permission. } else {/*from w w w. jav a 2 s .co m*/ // No explanation needed, we can request the permission. Log.e("Check", "Requesting"); ActivityCompat.requestPermissions(this, new String[] { Manifest.permission.CAMERA }, REQUEST_CAMERA_PERMISSION); // MY_PERMISSIONS_REQUEST_READ_CONTACTS is an // app-defined int constant. The callback method gets the // result of the request. } } else { Log.e("Check", "Already Granted"); //Already Permission Granted Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); startActivityForResult(intent, 1); } }
From source file:com.learnit.LearnIt.data_types.NotificationBuilder.java
private static boolean CreateNotifications(ArrayList<ArticleWordId> randWords, Context context, int wayToLearn) { ArrayList<Intent> intents = new ArrayList<Intent>(); ArrayList<Integer> ids = new ArrayList<Integer>(); ArrayList<String> words = new ArrayList<String>(); ArrayList<String> articles = new ArrayList<String>(); ArrayList<String> translations = new ArrayList<String>(); ArrayList<String> prefixes = new ArrayList<String>(); ArrayList<Integer> directionsOfTrans = new ArrayList<Integer>(); ArrayList<Integer> typesOfHomeworks = new ArrayList<Integer>(); ArrayList<Class> classes = new ArrayList<Class>(); for (ArticleWordId struct : randWords) { int homeworkActivityType = getHomeworkType(wayToLearn, struct.article); int directionOfTranslation = getDirectionOfTranslation(context, sp, homeworkActivityType); ids.add(struct.id + idModificator); words.add(struct.word);//from w ww . j ava 2 s . c om articles.add(struct.article); translations.add(struct.translation); prefixes.add(struct.prefix); intents.add(getIntentFromHomeworkType(context, homeworkActivityType)); typesOfHomeworks.add(homeworkActivityType); classes.add(getStackTypeFromHomeworkType(homeworkActivityType)); directionsOfTrans.add(directionOfTranslation); } for (int i = 0; i < intents.size(); ++i) { Intent intent = intents.get(i); intent.putExtra(IDS_TAG, ids); intent.putExtra(WORDS_TAG, words); intent.putExtra(TRANSLATIONS_TAG, translations); intent.putExtra(ARTICLES_TAG, articles); intent.putExtra(PREFIXES_TAG, prefixes); intent.putExtra(DIRECTIONS_OF_TRANS_TAG, directionsOfTrans); intent.putExtra(HOMEWORK_TYPE_TAG, typesOfHomeworks); intent.putExtra(CURRENT_NOTIFICATION_INDEX, i); intent.setAction(ids.get(i) + " " + words.get(i) + " " + System.currentTimeMillis()); NotificationCompat.Builder mBuilder; mBuilder = getBuilder(context, directionsOfTrans.get(i), randWords.get(i)); TaskStackBuilder stackBuilder = TaskStackBuilder.create(context); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS); stackBuilder.addParentStack(classes.get(i)); stackBuilder.addNextIntent(intent); PendingIntent pendInt = PendingIntent.getActivity(context, ids.get(i), intent, PendingIntent.FLAG_UPDATE_CURRENT); if (null != mBuilder) { mBuilder.setSmallIcon(Utils.getIconForWordNumber(i + 1)); mBuilder.setContentIntent(pendInt); mBuilder.setPriority(Notification.PRIORITY_MAX); mBuilder.setOngoing(true); NotificationManager mNotificationManager = (NotificationManager) context .getSystemService(Context.NOTIFICATION_SERVICE); mNotificationManager.notify(ids.get(i), mBuilder.build()); currentIds = currentIds + ids.get(i) + " "; } else return false; } return true; }
From source file:com.metinkale.prayerapp.vakit.AlarmReceiver.java
public void fireAlarm(Intent intent) throws InterruptedException { Context c = App.getContext(); if ((intent == null) || !intent.hasExtra("json")) { return;//from w ww .ja v a 2s. co m } Alarm next = Alarm.fromString(intent.getStringExtra("json")); intent.removeExtra("json"); if (next.city == 0) { return; } Times t = Times.getTimes(next.city); if (t == null) return; boolean active; if (next.cuma) { active = t.isCumaActive(); } else if (next.early) { active = t.isEarlyNotificationActive(next.vakit); } else { active = t.isNotificationActive(next.vakit); } if (!active) { return; } boolean vibrate; String sound; String dua; long silenter; if (next.cuma) { vibrate = t.hasCumaVibration(); sound = t.getCumaSound(); dua = "silent"; silenter = t.getCumaSilenterDuration(); } else if (next.early) { vibrate = t.hasEarlyVibration(next.vakit); sound = t.getEarlySound(next.vakit); dua = "silent"; silenter = t.getEarlySilenterDuration(next.vakit); } else { vibrate = t.hasVibration(next.vakit); sound = t.getSound(next.vakit); dua = t.getDua(next.vakit); silenter = t.getSilenterDuration(next.vakit); } NotificationManager nm = (NotificationManager) c.getSystemService(Context.NOTIFICATION_SERVICE); nm.cancel(next.city + "", NotIds.ALARM); String text; text = t.getName() + " (" + t.getSource() + ")"; String txt = ""; if (next.early) { String[] left_part = App.getContext().getResources().getStringArray(R.array.lefttext_part); txt = App.getContext().getString(R.string.earlyText, left_part[next.vakit.index], "" + t.getEarlyTime(next.vakit)); } else if (next.cuma) { String[] left_part = App.getContext().getResources().getStringArray(R.array.lefttext_part); txt = App.getContext().getString(R.string.earlyText, left_part[next.vakit.index], "" + t.getCumaTime()); } else if (next.vakit != null) { txt = next.vakit.getString(); } NotificationCompat.Builder builder = new NotificationCompat.Builder(c).setContentTitle(text) .setContentText(txt).setContentIntent(Main.getPendingIntent(t)).setSmallIcon(R.drawable.ic_abicon); Notification not = builder.build(); if (vibrate) { not.vibrate = VibrationPreference.getPattern(c, "vibration"); } AudioManager am = (AudioManager) c.getSystemService(Context.AUDIO_SERVICE); class MPHolder { MediaPlayer mp; } not.deleteIntent = PendingIntent.getBroadcast(c, 0, new Intent(c, Audio.class), PendingIntent.FLAG_UPDATE_CURRENT); nm.notify(next.city + "", NotIds.ALARM, not); final MPHolder mp = new MPHolder(); if (Prefs.showNotificationScreen() && (sound != null) && !sound.startsWith("silent")) { PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE); if (!pm.isScreenOn()) { Intent i = new Intent(c, NotificationPopup.class); i.putExtra("city", next.city); i.putExtra("name", text); i.putExtra("vakit", txt); i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS); c.startActivity(i); Thread.sleep(1000); } } sInterrupt = false; boolean hasSound = false; while ((sound != null) && !sound.startsWith("silent") && !sInterrupt) { int volume = -2; hasSound = true; if (!sound.startsWith("silent") && !sound.startsWith("picker")) { if (sound.contains("$volume")) { volume = Integer.parseInt(sound.substring(sound.indexOf("$volume") + 7)); sound = sound.substring(0, sound.indexOf("$volume")); } if (volume != -2) { int oldvalue = am.getStreamVolume(getStreamType(c)); am.setStreamVolume(getStreamType(c), volume, 0); volume = oldvalue; } try { mp.mp = play(c, sound); } catch (IOException e) { e.printStackTrace(); if (next.cuma) { t.setCumaSound("silent"); } else if (next.early) { t.setEarlySound(next.vakit, "silent"); } else { if ("sound".equals(t.getSound(next.vakit))) { t.setSound(next.vakit, "silent"); } else { t.setDua(next.vakit, "silent"); } } mp.mp = null; } if (mp.mp != null) { mp.mp.setOnCompletionListener(new MediaPlayer.OnCompletionListener() { @Override public void onCompletion(MediaPlayer mediaPlayer) { if (mp.mp == null) { return; } mp.mp.stop(); mp.mp.release(); mp.mp = null; } }); mp.mp.setOnSeekCompleteListener(new MediaPlayer.OnSeekCompleteListener() { @Override public void onSeekComplete(MediaPlayer mediaPlayer) { if (mp.mp == null) { return; } mp.mp.stop(); mp.mp.release(); mp.mp = null; } }); } sInterrupt = false; while ((mp.mp != null) && mp.mp.isPlaying()) { if (sInterrupt) { mp.mp.stop(); mp.mp.release(); mp.mp = null; dua = null; } else { try { Thread.sleep(500); } catch (InterruptedException ignore) { } } } sInterrupt = false; } if (volume != -2) { am.setStreamVolume(getStreamType(c), volume, 0); } sound = dua; dua = null; } if (hasSound && Prefs.autoRemoveNotification()) { nm.cancel(next.city + "", NotIds.ALARM); } if (silenter != 0) { silenter(c, silenter); } }
From source file:de.vanita5.twittnuker.service.BackgroundOperationService.java
private Notification buildNotification(final String title, final String message, final int icon, final Intent content_intent, final Intent delete_intent, boolean showProgress) { final NotificationCompat.Builder builder = new NotificationCompat.Builder(this); builder.setTicker(message);/* www . ja v a 2 s . c o m*/ builder.setContentTitle(title); builder.setContentText(message); builder.setAutoCancel(true); builder.setWhen(System.currentTimeMillis()); builder.setSmallIcon(icon); if (showProgress) builder.setProgress(0, 0, true); if (delete_intent != null) { builder.setDeleteIntent( PendingIntent.getBroadcast(this, 0, delete_intent, PendingIntent.FLAG_UPDATE_CURRENT)); } if (content_intent != null) { content_intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS); builder.setContentIntent( PendingIntent.getActivity(this, 0, content_intent, PendingIntent.FLAG_UPDATE_CURRENT)); } // final Uri defRingtone = // RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION); // final String path = // mPreferences.getString(KEY_NOTIFICATION_RINGTONE, ""); // builder.setSound(isEmpty(path) ? defRingtone : Uri.parse(path), // Notification.STREAM_DEFAULT); // builder.setLights(HOLO_BLUE_LIGHT, 1000, 2000); // builder.setDefaults(Notification.DEFAULT_VIBRATE); return builder.build(); }
From source file:com.android.screenspeak.ScreenSpeakUpdateHelper.java
/** * Persists old default gestures (or preserves explicit user-defined * gestures) and posts the gesture change notification. */// w ww . j a v a 2 s.com private void notifyUserOfGestureChanges() { final Editor editor = mSharedPreferences.edit(); // Manually persist old defaults until the user acknowledges the change. deprecateStringPreference(editor, R.string.pref_shortcut_down_and_left_key, R.string.pref_deprecated_shortcut_down_and_left_default); deprecateStringPreference(editor, R.string.pref_shortcut_down_and_right_key, R.string.pref_deprecated_shortcut_down_and_right_default); deprecateStringPreference(editor, R.string.pref_shortcut_up_and_left_key, R.string.pref_deprecated_shortcut_up_and_left_default); deprecateStringPreference(editor, R.string.pref_shortcut_up_and_right_key, R.string.pref_deprecated_shortcut_up_and_right_default); // Flag that this user needs to get through the notification flow. editor.putBoolean(mService.getString(R.string.pref_must_accept_gesture_change_notification), true); editor.apply(); // Build the intent for when the notification is clicked. final Intent notificationIntent = new Intent(mService, GestureChangeNotificationActivity.class); notificationIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); notificationIntent.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS); NotificationPosterRunnable runnable = new NotificationPosterRunnable( buildGestureChangeNotification(notificationIntent), GESTURE_CHANGE_NOTIFICATION_ID); mHandler.postDelayed(runnable, NOTIFICATION_DELAY); }