List of usage examples for android.content Intent FLAG_ACTIVITY_NO_USER_ACTION
int FLAG_ACTIVITY_NO_USER_ACTION
To view the source code for android.content Intent FLAG_ACTIVITY_NO_USER_ACTION.
Click Source Link
From source file:com.android.deskclock.data.TimerNotificationBuilderN.java
@Override public Notification buildHeadsUp(Context context, List<Timer> expired) { final Timer timer = expired.get(0); // First action intent is to reset all timers. final Icon icon1 = Icon.createWithResource(context, R.drawable.ic_stop_24dp); final Intent reset = TimerService.createResetExpiredTimersIntent(context); final PendingIntent intent1 = Utils.pendingServiceIntent(context, reset); // Generate some descriptive text, a title, and an action name based on the timer count. final CharSequence stateText; final int count = expired.size(); final List<Notification.Action> actions = new ArrayList<>(2); if (count == 1) { final String label = timer.getLabel(); if (TextUtils.isEmpty(label)) { stateText = context.getString(R.string.timer_times_up); } else {// w w w. java 2 s . c o m stateText = label; } // Left button: Reset single timer final CharSequence title1 = context.getString(R.string.timer_stop); actions.add(new Notification.Action.Builder(icon1, title1, intent1).build()); // Right button: Add minute final Intent addTime = TimerService.createAddMinuteTimerIntent(context, timer.getId()); final PendingIntent intent2 = Utils.pendingServiceIntent(context, addTime); final Icon icon2 = Icon.createWithResource(context, R.drawable.ic_add_24dp); final CharSequence title2 = context.getString(R.string.timer_plus_1_min); actions.add(new Notification.Action.Builder(icon2, title2, intent2).build()); } else { stateText = context.getString(R.string.timer_multi_times_up, count); // Left button: Reset all timers final CharSequence title1 = context.getString(R.string.timer_stop_all); actions.add(new Notification.Action.Builder(icon1, title1, intent1).build()); } final long base = getChronometerBase(timer); final String pname = context.getPackageName(); final RemoteViews contentView = new RemoteViews(pname, R.layout.chronometer_notif_content); contentView.setChronometerCountDown(R.id.chronometer, true); contentView.setChronometer(R.id.chronometer, base, null, true); contentView.setTextViewText(R.id.state, stateText); // Content intent shows the timer full screen when clicked. final Intent content = new Intent(context, ExpiredTimersActivity.class); final PendingIntent contentIntent = Utils.pendingActivityIntent(context, content); // Full screen intent has flags so it is different than the content intent. final Intent fullScreen = new Intent(context, ExpiredTimersActivity.class) .setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_NO_USER_ACTION); final PendingIntent pendingFullScreen = Utils.pendingActivityIntent(context, fullScreen); return new Notification.Builder(context).setOngoing(true).setLocalOnly(true).setShowWhen(false) .setAutoCancel(false).setContentIntent(contentIntent).setCustomContentView(contentView) .setPriority(Notification.PRIORITY_MAX).setDefaults(Notification.DEFAULT_LIGHTS) .setColor(ContextCompat.getColor(context, R.color.default_background)) .setSmallIcon(R.drawable.stat_notify_timer).setFullScreenIntent(pendingFullScreen, true) .setStyle(new Notification.DecoratedCustomViewStyle()) .setActions(actions.toArray(new Notification.Action[actions.size()])).build(); }
From source file:com.wizardsofm.deskclock.data.TimerNotificationBuilderN.java
@Override public Notification buildHeadsUp(Context context, List<Timer> expired) { final Timer timer = expired.get(0); // First action intent is to reset all timers. final Icon icon1 = Icon.createWithResource(context, com.wizardsofm.deskclock.R.drawable.ic_stop_24dp); final Intent reset = TimerService.createResetExpiredTimersIntent(context); final PendingIntent intent1 = Utils.pendingServiceIntent(context, reset); // Generate some descriptive text, a title, and an action name based on the timer count. final CharSequence stateText; final int count = expired.size(); final List<Notification.Action> actions = new ArrayList<>(2); if (count == 1) { final String label = timer.getLabel(); if (TextUtils.isEmpty(label)) { stateText = context.getString(com.wizardsofm.deskclock.R.string.timer_times_up); } else {//from ww w .j av a 2 s .c o m stateText = label; } // Left button: Reset single timer final CharSequence title1 = context.getString(com.wizardsofm.deskclock.R.string.timer_stop); actions.add(new Notification.Action.Builder(icon1, title1, intent1).build()); // Right button: Add minute final Intent addTime = TimerService.createAddMinuteTimerIntent(context, timer.getId()); final PendingIntent intent2 = Utils.pendingServiceIntent(context, addTime); final Icon icon2 = Icon.createWithResource(context, com.wizardsofm.deskclock.R.drawable.ic_add_24dp); final CharSequence title2 = context.getString(com.wizardsofm.deskclock.R.string.timer_plus_1_min); actions.add(new Notification.Action.Builder(icon2, title2, intent2).build()); } else { stateText = context.getString(com.wizardsofm.deskclock.R.string.timer_multi_times_up, count); // Left button: Reset all timers final CharSequence title1 = context.getString(com.wizardsofm.deskclock.R.string.timer_stop_all); actions.add(new Notification.Action.Builder(icon1, title1, intent1).build()); } final long base = getChronometerBase(timer); final String pname = context.getPackageName(); final RemoteViews contentView = new RemoteViews(pname, com.wizardsofm.deskclock.R.layout.chronometer_notif_content); contentView.setChronometerCountDown(com.wizardsofm.deskclock.R.id.chronometer, true); contentView.setChronometer(com.wizardsofm.deskclock.R.id.chronometer, base, null, true); contentView.setTextViewText(com.wizardsofm.deskclock.R.id.state, stateText); // Content intent shows the timer full screen when clicked. final Intent content = new Intent(context, ExpiredTimersActivity.class); final PendingIntent contentIntent = Utils.pendingActivityIntent(context, content); // Full screen intent has flags so it is different than the content intent. final Intent fullScreen = new Intent(context, ExpiredTimersActivity.class) .setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_NO_USER_ACTION); final PendingIntent pendingFullScreen = Utils.pendingActivityIntent(context, fullScreen); return new Notification.Builder(context).setOngoing(true).setLocalOnly(true).setShowWhen(false) .setAutoCancel(false).setContentIntent(contentIntent).setCustomContentView(contentView) .setPriority(Notification.PRIORITY_MAX).setDefaults(Notification.DEFAULT_LIGHTS) .setColor(ContextCompat.getColor(context, com.wizardsofm.deskclock.R.color.default_background)) .setSmallIcon(com.wizardsofm.deskclock.R.drawable.stat_notify_timer) .setFullScreenIntent(pendingFullScreen, true).setStyle(new Notification.DecoratedCustomViewStyle()) .setActions(actions.toArray(new Notification.Action[actions.size()])).build(); }
From source file:com.klinker.deskclock.alarms.AlarmNotifications.java
public static void showAlarmNotification(Context context, AlarmInstance instance) { Log.v("Displaying alarm notification for alarm instance: " + instance.mId); NotificationManager nm = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); // Close dialogs and window shade, so this will display context.sendBroadcast(new Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS)); Resources resources = context.getResources(); NotificationCompat.Builder notification = new NotificationCompat.Builder(context) .setContentTitle(instance.getLabelOrDefault(context)) .setContentText(AlarmUtils.getFormattedTime(context, instance.getAlarmTime())) .setSmallIcon(R.drawable.stat_notify_alarm).setOngoing(true).setAutoCancel(false).setWhen(0); // Setup Snooze Action Intent snoozeIntent = AlarmStateManager.createStateChangeIntent(context, "SNOOZE_TAG", instance, AlarmInstance.SNOOZE_STATE); PendingIntent snoozePendingIntent = PendingIntent.getBroadcast(context, instance.hashCode(), snoozeIntent, PendingIntent.FLAG_UPDATE_CURRENT); notification.addAction(R.drawable.stat_notify_alarm, resources.getString(R.string.alarm_alert_snooze_text), snoozePendingIntent);// w w w. j a va2 s . com // Setup Dismiss Action Intent dismissIntent = AlarmStateManager.createStateChangeIntent(context, "DISMISS_TAG", instance, AlarmInstance.DISMISSED_STATE); PendingIntent dismissPendingIntent = PendingIntent.getBroadcast(context, instance.hashCode(), dismissIntent, PendingIntent.FLAG_UPDATE_CURRENT); notification.addAction(android.R.drawable.ic_menu_close_clear_cancel, resources.getString(R.string.alarm_alert_dismiss_text), dismissPendingIntent); // Setup Content Action Intent contentIntent = AlarmInstance.createIntent(context, AlarmActivity.class, instance.mId); notification.setContentIntent(PendingIntent.getActivity(context, instance.hashCode(), contentIntent, PendingIntent.FLAG_UPDATE_CURRENT)); // Setup fullscreen intent Intent fullScreenIntent = AlarmInstance.createIntent(context, AlarmActivity.class, instance.mId); // set action, so we can be different then content pending intent fullScreenIntent.setAction("fullscreen_activity"); fullScreenIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_NO_USER_ACTION); notification.setFullScreenIntent(PendingIntent.getActivity(context, instance.hashCode(), fullScreenIntent, PendingIntent.FLAG_UPDATE_CURRENT), true); notification.setPriority(NotificationCompat.PRIORITY_MAX); nm.cancel(instance.hashCode()); nm.notify(instance.hashCode(), notification.build()); }
From source file:se.oort.clockify.alarms.AlarmNotifications.java
public static void showAlarmNotification(Context context, AlarmInstance instance) { Log.v(LOG_TAG, "Displaying alarm notification for alarm instance: " + instance.mId); NotificationManager nm = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); // Close dialogs and window shade, so this will display context.sendBroadcast(new Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS)); Resources resources = context.getResources(); NotificationCompat.Builder notification = new NotificationCompat.Builder(context) .setContentTitle(instance.getLabelOrDefault(context)) .setContentText(AlarmUtils.getFormattedTime(context, instance.getAlarmTime())) .setSmallIcon(R.drawable.stat_notify_alarm).setOngoing(true).setAutoCancel(false).setWhen(0); // Setup Snooze Action Intent snoozeIntent = AlarmStateManager.createStateChangeIntent(context, "SNOOZE_TAG", instance, AlarmInstance.SNOOZE_STATE); PendingIntent snoozePendingIntent = PendingIntent.getBroadcast(context, instance.hashCode(), snoozeIntent, PendingIntent.FLAG_UPDATE_CURRENT); notification.addAction(R.drawable.stat_notify_alarm, resources.getString(R.string.alarm_alert_snooze_text), snoozePendingIntent);//from ww w . j a v a2 s. co m // Setup Dismiss Action Intent dismissIntent = AlarmStateManager.createStateChangeIntent(context, "DISMISS_TAG", instance, AlarmInstance.DISMISSED_STATE); PendingIntent dismissPendingIntent = PendingIntent.getBroadcast(context, instance.hashCode(), dismissIntent, PendingIntent.FLAG_UPDATE_CURRENT); notification.addAction(android.R.drawable.ic_menu_close_clear_cancel, resources.getString(R.string.alarm_alert_dismiss_text), dismissPendingIntent); // Setup Content Action Intent contentIntent = AlarmInstance.createIntent(context, AlarmActivity.class, instance.mId); notification.setContentIntent(PendingIntent.getActivity(context, instance.hashCode(), contentIntent, PendingIntent.FLAG_UPDATE_CURRENT)); // Setup fullscreen intent Intent fullScreenIntent = AlarmInstance.createIntent(context, AlarmActivity.class, instance.mId); // set action, so we can be different then content pending intent fullScreenIntent.setAction("fullscreen_activity"); fullScreenIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_NO_USER_ACTION); notification.setFullScreenIntent(PendingIntent.getActivity(context, instance.hashCode(), fullScreenIntent, PendingIntent.FLAG_UPDATE_CURRENT), true); notification.setPriority(NotificationCompat.PRIORITY_MAX); nm.cancel(instance.hashCode()); nm.notify(instance.hashCode(), notification.build()); }
From source file:com.heightechllc.breakify.MainActivity.java
/** * Handles a new intent, either from onNewIntent() or onCreate() * @param intent The intent to handle/*w w w. j a va 2s.c om*/ * @return Whether we should attempt to restore the saved timer state. Will be false when * this method opens another Activity. */ private boolean handleIntent(Intent intent) { boolean shouldRestoreSavedTimer = true; if (intent.getBooleanExtra(EXTRA_SNOOZE, false)) { // The activity was launched from the expanded notification's "Snooze" action snoozeTimer(); // In case user didn't interact with the RingingActivity, and instead snoozed directly // from the notification AlarmRinger.stop(this); // Don't restore, since we're about to open a new Activity shouldRestoreSavedTimer = false; } else if (intent.getBooleanExtra(EXTRA_ALARM_RING, false)) { // The Activity was launched from AlarmReceiver, meaning the timer finished and we // need to ring the alarm Intent ringingIntent = new Intent(this, RingingActivity.class); // Pass along FLAG_ACTIVITY_NO_USER_ACTION if it was set when calling this activity if ((intent.getFlags() & Intent.FLAG_ACTIVITY_NO_USER_ACTION) != 0) ringingIntent.setFlags(Intent.FLAG_ACTIVITY_NO_USER_ACTION); startActivityForResult(ringingIntent, RingingActivity.REQUEST_ALARM_RING); // Don't restore, since we're about to open a new Activity shouldRestoreSavedTimer = false; } else if (intent.getBooleanExtra(EXTRA_SCHEDULED_START, false)) { // The Activity was launched from ScheduledStartReceiver, meaning it's time for the // scheduled start // Show a dialog prompting the user to start new AlertDialog.Builder(this).setTitle(R.string.scheduled_dialog_title) .setMessage(R.string.scheduled_dialog_message) .setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { // Start the timer circleTimer.performClick(); } }).setNeutralButton(R.string.action_settings, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { // Show the settings activity with the Scheduled Start settings Intent intent = new Intent(MainActivity.this, SettingsActivity.class); intent.putExtra(PreferenceActivity.EXTRA_SHOW_FRAGMENT, ScheduledStartSettingsFragment.class.getName()); intent.putExtra(PreferenceActivity.EXTRA_SHOW_FRAGMENT_TITLE, R.string.pref_category_scheduled); startActivity(intent); } }).setNegativeButton(R.string.cancel, null).show(); } return shouldRestoreSavedTimer; }
From source file:com.embeddedlog.LightUpDroid.alarms.AlarmNotifications.java
public static void showAlarmNotification(Context context, AlarmInstance instance) { Log.v("Displaying alarm notification for alarm instance: " + instance.mId); NotificationManager nm = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); // Close dialogs and window shade, so this will display context.sendBroadcast(new Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS)); Resources resources = context.getResources(); NotificationCompat.Builder notification = new NotificationCompat.Builder(context) .setContentTitle(instance.getLabelOrDefault(context)) .setContentText(AlarmUtils.getFormattedTime(context, instance.getAlarmTime())) .setSmallIcon(R.drawable.stat_notify_alarm).setOngoing(true).setAutoCancel(false) .setDefaults(NotificationCompat.DEFAULT_LIGHTS).setWhen(0) .setCategory(NotificationCompat.CATEGORY_ALARM); // Setup Snooze Action Intent snoozeIntent = AlarmStateManager.createStateChangeIntent(context, "SNOOZE_TAG", instance, AlarmInstance.SNOOZE_STATE); PendingIntent snoozePendingIntent = PendingIntent.getBroadcast(context, instance.hashCode(), snoozeIntent, PendingIntent.FLAG_UPDATE_CURRENT); notification.addAction(R.drawable.stat_notify_alarm, resources.getString(R.string.alarm_alert_snooze_text), snoozePendingIntent);/*from w w w . ja v a2 s . c o m*/ // Setup Dismiss Action Intent dismissIntent = AlarmStateManager.createStateChangeIntent(context, "DISMISS_TAG", instance, AlarmInstance.DISMISSED_STATE); PendingIntent dismissPendingIntent = PendingIntent.getBroadcast(context, instance.hashCode(), dismissIntent, PendingIntent.FLAG_UPDATE_CURRENT); notification.addAction(android.R.drawable.ic_menu_close_clear_cancel, resources.getString(R.string.alarm_alert_dismiss_text), dismissPendingIntent); // Setup Content Action Intent contentIntent = AlarmInstance.createIntent(context, AlarmActivity.class, instance.mId); notification.setContentIntent(PendingIntent.getActivity(context, instance.hashCode(), contentIntent, PendingIntent.FLAG_UPDATE_CURRENT)); // Setup fullscreen intent Intent fullScreenIntent = AlarmInstance.createIntent(context, AlarmActivity.class, instance.mId); // set action, so we can be different then content pending intent fullScreenIntent.setAction("fullscreen_activity"); fullScreenIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_NO_USER_ACTION); notification.setFullScreenIntent(PendingIntent.getActivity(context, instance.hashCode(), fullScreenIntent, PendingIntent.FLAG_UPDATE_CURRENT), true); notification.setPriority(NotificationCompat.PRIORITY_MAX); nm.cancel(instance.hashCode()); nm.notify(instance.hashCode(), notification.build()); }
From source file:com.androidinspain.deskclock.data.TimerNotificationBuilder.java
Notification buildHeadsUp(Context context, List<Timer> expired) { final Timer timer = expired.get(0); // First action intent is to reset all timers. @DrawableRes/*www . j av a 2 s .co m*/ final int icon1 = com.androidinspain.deskclock.R.drawable.ic_stop_24dp; final Intent reset = TimerService.createResetExpiredTimersIntent(context); final PendingIntent intent1 = Utils.pendingServiceIntent(context, reset); // Generate some descriptive text, a title, and an action name based on the timer count. final CharSequence stateText; final int count = expired.size(); final List<Action> actions = new ArrayList<>(2); if (count == 1) { final String label = timer.getLabel(); if (TextUtils.isEmpty(label)) { stateText = context.getString(com.androidinspain.deskclock.R.string.timer_times_up); } else { stateText = label; } // Left button: Reset single timer final CharSequence title1 = context.getString(com.androidinspain.deskclock.R.string.timer_stop); actions.add(new Action.Builder(icon1, title1, intent1).build()); // Right button: Add minute final Intent addTime = TimerService.createAddMinuteTimerIntent(context, timer.getId()); final PendingIntent intent2 = Utils.pendingServiceIntent(context, addTime); @DrawableRes final int icon2 = com.androidinspain.deskclock.R.drawable.ic_add_24dp; final CharSequence title2 = context.getString(com.androidinspain.deskclock.R.string.timer_plus_1_min); actions.add(new Action.Builder(icon2, title2, intent2).build()); } else { stateText = context.getString(com.androidinspain.deskclock.R.string.timer_multi_times_up, count); // Left button: Reset all timers final CharSequence title1 = context.getString(com.androidinspain.deskclock.R.string.timer_stop_all); actions.add(new Action.Builder(icon1, title1, intent1).build()); } final long base = getChronometerBase(timer); final String pname = context.getPackageName(); // Content intent shows the timer full screen when clicked. final Intent content = new Intent(context, ExpiredTimersActivity.class); final PendingIntent contentIntent = Utils.pendingActivityIntent(context, content); // Full screen intent has flags so it is different than the content intent. final Intent fullScreen = new Intent(context, ExpiredTimersActivity.class) .setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_NO_USER_ACTION); final PendingIntent pendingFullScreen = Utils.pendingActivityIntent(context, fullScreen); final Builder notification = new NotificationCompat.Builder(context).setOngoing(true).setLocalOnly(true) .setShowWhen(false).setAutoCancel(false).setContentIntent(contentIntent) .setPriority(Notification.PRIORITY_MAX).setDefaults(Notification.DEFAULT_LIGHTS) .setSmallIcon(com.androidinspain.deskclock.R.drawable.stat_notify_timer) .setFullScreenIntent(pendingFullScreen, true) .setStyle(new NotificationCompat.DecoratedCustomViewStyle()) .setColor(ContextCompat.getColor(context, com.androidinspain.deskclock.R.color.default_background)); for (Action action : actions) { notification.addAction(action); } if (Utils.isNOrLater()) { notification.setCustomContentView(buildChronometer(pname, base, true, stateText)); } else { final CharSequence contentTextPreN = count == 1 ? context.getString(com.androidinspain.deskclock.R.string.timer_times_up) : context.getString(com.androidinspain.deskclock.R.string.timer_multi_times_up, count); notification.setContentTitle(stateText).setContentText(contentTextPreN); } return notification.build(); }
From source file:com.zigvine.zagriculture.UIActivity.java
@Override public void startActivityForResult(Intent intent, int requestCode) { ActivityInfo info = intent.resolveActivityInfo(getPackageManager(), 0); if (info != null && info.packageName != null && info.packageName.equals(getPackageName())) { intent.addFlags(Intent.FLAG_ACTIVITY_NO_USER_ACTION); }/*from w w w .ja v a 2 s . c om*/ super.startActivityForResult(intent, requestCode); }
From source file:com.stasbar.knowyourself.alarms.AlarmNotifications.java
public static void showAlarmNotification(Service service, AlarmInstance instance) { LogUtils.v("Displaying alarm notification for alarm instance: " + instance.mId); Resources resources = service.getResources(); NotificationCompat.Builder notification = new NotificationCompat.Builder(service) .setContentTitle(instance.getLabelOrDefault(service)) .setContentText(AlarmUtils.getFormattedTime(service, instance.getAlarmTime())) .setColor(ContextCompat.getColor(service, R.color.default_background)) .setSmallIcon(R.drawable.stat_notify_alarm).setOngoing(true).setAutoCancel(false) .setDefaults(NotificationCompat.DEFAULT_LIGHTS).setWhen(0) .setCategory(NotificationCompat.CATEGORY_ALARM).setVisibility(NotificationCompat.VISIBILITY_PUBLIC) .setLocalOnly(true);/*w w w . ja v a 2 s. co m*/ // Setup Snooze Action Intent snoozeIntent = AlarmStateManager.createStateChangeIntent(service, AlarmStateManager.ALARM_SNOOZE_TAG, instance, AlarmInstance.SNOOZE_STATE); snoozeIntent.putExtra(AlarmStateManager.FROM_NOTIFICATION_EXTRA, true); PendingIntent snoozePendingIntent = PendingIntent.getService(service, instance.hashCode(), snoozeIntent, PendingIntent.FLAG_UPDATE_CURRENT); notification.addAction(R.drawable.ic_snooze_24dp, resources.getString(R.string.alarm_alert_snooze_text), snoozePendingIntent); // Setup Dismiss Action Intent dismissIntent = AlarmStateManager.createStateChangeIntent(service, AlarmStateManager.ALARM_DISMISS_TAG, instance, AlarmInstance.DISMISSED_STATE); dismissIntent.putExtra(AlarmStateManager.FROM_NOTIFICATION_EXTRA, true); PendingIntent dismissPendingIntent = PendingIntent.getService(service, instance.hashCode(), dismissIntent, PendingIntent.FLAG_UPDATE_CURRENT); notification.addAction(R.drawable.ic_alarm_off_24dp, resources.getString(R.string.alarm_alert_dismiss_text), dismissPendingIntent); // Setup Content Action Intent contentIntent = AlarmInstance.createIntent(service, AlarmActivity.class, instance.mId); notification.setContentIntent(PendingIntent.getActivity(service, instance.hashCode(), contentIntent, PendingIntent.FLAG_UPDATE_CURRENT)); // Setup fullscreen intent Intent fullScreenIntent = AlarmInstance.createIntent(service, AlarmActivity.class, instance.mId); // set action, so we can be different then content pending intent fullScreenIntent.setAction("fullscreen_activity"); fullScreenIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_NO_USER_ACTION); notification.setFullScreenIntent(PendingIntent.getActivity(service, instance.hashCode(), fullScreenIntent, PendingIntent.FLAG_UPDATE_CURRENT), true); notification.setPriority(NotificationCompat.PRIORITY_MAX); clearNotification(service, instance); service.startForeground(instance.hashCode(), notification.build()); }
From source file:org.telegram.messenger.NotificationsController.java
public void processNewMessages(final ArrayList<MessageObject> messageObjects, final boolean isLast) { if (messageObjects.isEmpty()) { return;/*from ww w .j a v a 2s . c o m*/ } final ArrayList<MessageObject> popupArray = new ArrayList<>(popupMessages); notificationsQueue.postRunnable(new Runnable() { @Override public void run() { boolean added = false; int oldCount = popupArray.size(); HashMap<Long, Boolean> settingsCache = new HashMap<>(); SharedPreferences preferences = ApplicationLoader.applicationContext .getSharedPreferences("Notifications", Context.MODE_PRIVATE); int popup = 0; for (int a = 0; a < messageObjects.size(); a++) { MessageObject messageObject = messageObjects.get(a); long mid = messageObject.messageOwner.id; if (messageObject.messageOwner.to_id.channel_id != 0) { mid |= ((long) messageObject.messageOwner.to_id.channel_id) << 32; } if (pushMessagesDict.containsKey(mid)) { continue; } long dialog_id = messageObject.getDialogId(); long original_dialog_id = dialog_id; if (dialog_id == openned_dialog_id && ApplicationLoader.isScreenOn) { playInChatSound(); continue; } if ((messageObject.messageOwner.flags & TLRPC.MESSAGE_FLAG_MENTION) != 0) { dialog_id = messageObject.messageOwner.from_id; } if (isPersonalMessage(messageObject)) { personal_count++; } added = true; Boolean value = settingsCache.get(dialog_id); boolean isChat = (int) dialog_id < 0; popup = (int) dialog_id == 0 ? 0 : preferences.getInt(isChat ? "popupGroup" : "popupAll", 0); if (value == null) { int notifyOverride = getNotifyOverride(preferences, dialog_id); value = !(notifyOverride == 2 || (!preferences.getBoolean("EnableAll", true) || isChat && !preferences.getBoolean("EnableGroup", true)) && notifyOverride == 0); settingsCache.put(dialog_id, value); } if (value) { if (popup != 0) { popupArray.add(0, messageObject); } delayedPushMessages.add(messageObject); pushMessages.add(0, messageObject); pushMessagesDict.put(mid, messageObject); if (original_dialog_id != dialog_id) { pushDialogsOverrideMention.put(original_dialog_id, 1); } } } if (added) { notifyCheck = isLast; } if (!popupArray.isEmpty() && oldCount != popupArray.size() && !AndroidUtilities.needShowPasscode(false)) { final int popupFinal = popup; AndroidUtilities.runOnUIThread(new Runnable() { @Override public void run() { popupMessages = popupArray; if (ApplicationLoader.mainInterfacePaused || !ApplicationLoader.isScreenOn && !UserConfig.isWaitingForPasscodeEnter) { MessageObject messageObject = messageObjects.get(0); if (popupFinal == 3 || popupFinal == 1 && ApplicationLoader.isScreenOn || popupFinal == 2 && !ApplicationLoader.isScreenOn) { Intent popupIntent = new Intent(ApplicationLoader.applicationContext, PopupNotificationActivity.class); popupIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_NO_ANIMATION | Intent.FLAG_ACTIVITY_NO_USER_ACTION | Intent.FLAG_FROM_BACKGROUND); ApplicationLoader.applicationContext.startActivity(popupIntent); } } } }); } } }); }