List of usage examples for android.content Intent FLAG_FROM_BACKGROUND
int FLAG_FROM_BACKGROUND
To view the source code for android.content Intent FLAG_FROM_BACKGROUND.
Click Source Link
From source file:com.synox.android.files.services.FileUploader.java
/** * Updates the status notification with the result of an upload operation. * * @param uploadResult Result of the upload operation. * @param upload Finished upload operation *//* ww w. jav a2 s.com*/ private void notifyUploadResult(RemoteOperationResult uploadResult, UploadFileOperation upload) { Log_OC.d(TAG, "NotifyUploadResult with resultCode: " + uploadResult.getCode()); // / cancelled operation or success -> silent removal of progress notification mNotificationManager.cancel(R.string.uploader_upload_in_progress_ticker); // Show the result: success or fail notification if (!uploadResult.isCancelled()) { int tickerId = (uploadResult.isSuccess()) ? R.string.uploader_upload_succeeded_ticker : R.string.uploader_upload_failed_ticker; String content; // check credentials error boolean needsToUpdateCredentials = (uploadResult.getCode() == ResultCode.UNAUTHORIZED || uploadResult.isIdPRedirection()); tickerId = (needsToUpdateCredentials) ? R.string.uploader_upload_failed_credentials_error : tickerId; mNotificationBuilder.setTicker(getString(tickerId)).setContentTitle(getString(tickerId)) .setAutoCancel(true).setOngoing(false).setProgress(0, 0, false); content = ErrorMessageAdapter.getErrorCauseMessage(uploadResult, upload, getResources()); if (needsToUpdateCredentials) { // let the user update credentials with one click Intent updateAccountCredentials = new Intent(this, AuthenticatorActivity.class); updateAccountCredentials.putExtra(AuthenticatorActivity.EXTRA_ACCOUNT, upload.getAccount()); updateAccountCredentials.putExtra(AuthenticatorActivity.EXTRA_ACTION, AuthenticatorActivity.ACTION_UPDATE_EXPIRED_TOKEN); updateAccountCredentials.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); updateAccountCredentials.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS); updateAccountCredentials.addFlags(Intent.FLAG_FROM_BACKGROUND); mNotificationBuilder.setContentIntent(PendingIntent.getActivity(this, (int) System.currentTimeMillis(), updateAccountCredentials, PendingIntent.FLAG_ONE_SHOT)); mUploadClient = null; // grant that future retries on the same account will get the fresh credentials } else { mNotificationBuilder.setContentText(content); if (upload.isInstant()) { DbHandler db = null; try { db = new DbHandler(this.getBaseContext()); String message = uploadResult.getLogMessage() + " errorCode: " + uploadResult.getCode(); Log_OC.e(TAG, message + " Http-Code: " + uploadResult.getHttpCode()); if (uploadResult.getCode() == ResultCode.QUOTA_EXCEEDED) { //message = getString(R.string.failed_upload_quota_exceeded_text); if (db.updateFileState(upload.getOriginalStoragePath(), message) == 0) { db.putFileForLater(upload.getOriginalStoragePath(), upload.getAccount().name, message); } } } finally { if (db != null) { db.close(); } } } } mNotificationBuilder.setContentText(content); mNotificationManager.notify(tickerId, mNotificationBuilder.build()); if (uploadResult.isSuccess()) { DbHandler db = new DbHandler(this.getBaseContext()); db.removeIUPendingFile(mCurrentUpload.getOriginalStoragePath()); db.close(); // remove success notification, with a delay of 2 seconds NotificationDelayer.cancelWithDelay(mNotificationManager, R.string.uploader_upload_succeeded_ticker, 2000); } } }
From source file:com.cerema.cloud2.files.services.FileUploader.java
/** * Updates the status notification with the result of an upload operation. * * @param uploadResult Result of the upload operation. * @param upload Finished upload operation *//*from w ww.j a v a2 s .c o m*/ private void notifyUploadResult(UploadFileOperation upload, RemoteOperationResult uploadResult) { Log_OC.d(TAG, "NotifyUploadResult with resultCode: " + uploadResult.getCode()); // / cancelled operation or success -> silent removal of progress notification mNotificationManager.cancel(R.string.uploader_upload_in_progress_ticker); // Show the result: success or fail notification if (!uploadResult.isCancelled()) { int tickerId = (uploadResult.isSuccess()) ? R.string.uploader_upload_succeeded_ticker : R.string.uploader_upload_failed_ticker; String content; // check credentials error boolean needsToUpdateCredentials = (uploadResult.getCode() == ResultCode.UNAUTHORIZED || uploadResult.isIdPRedirection()); tickerId = (needsToUpdateCredentials) ? R.string.uploader_upload_failed_credentials_error : tickerId; mNotificationBuilder.setTicker(getString(tickerId)).setContentTitle(getString(tickerId)) .setAutoCancel(true).setOngoing(false).setProgress(0, 0, false); content = ErrorMessageAdapter.getErrorCauseMessage(uploadResult, upload, getResources()); if (needsToUpdateCredentials) { // let the user update credentials with one click Intent updateAccountCredentials = new Intent(this, AuthenticatorActivity.class); updateAccountCredentials.putExtra(AuthenticatorActivity.EXTRA_ACCOUNT, upload.getAccount()); updateAccountCredentials.putExtra(AuthenticatorActivity.EXTRA_ACTION, AuthenticatorActivity.ACTION_UPDATE_EXPIRED_TOKEN); updateAccountCredentials.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); updateAccountCredentials.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS); updateAccountCredentials.addFlags(Intent.FLAG_FROM_BACKGROUND); mNotificationBuilder.setContentIntent(PendingIntent.getActivity(this, (int) System.currentTimeMillis(), updateAccountCredentials, PendingIntent.FLAG_ONE_SHOT)); mUploadClient = null; // grant that future retries on the same account will get the fresh credentials } else { mNotificationBuilder.setContentText(content); if (upload.isInstant()) { DbHandler db = null; try { db = new DbHandler(this.getBaseContext()); String message = uploadResult.getLogMessage() + " errorCode: " + uploadResult.getCode(); Log_OC.e(TAG, message + " Http-Code: " + uploadResult.getHttpCode()); if (uploadResult.getCode() == ResultCode.QUOTA_EXCEEDED) { //message = getString(R.string.failed_upload_quota_exceeded_text); if (db.updateFileState(upload.getOriginalStoragePath(), DbHandler.UPLOAD_STATUS_UPLOAD_FAILED, message) == 0) { db.putFileForLater(upload.getOriginalStoragePath(), upload.getAccount().name, message); } } } finally { if (db != null) { db.close(); } } } } mNotificationBuilder.setContentText(content); mNotificationManager.notify(tickerId, mNotificationBuilder.build()); if (uploadResult.isSuccess()) { DbHandler db = new DbHandler(this.getBaseContext()); db.removeIUPendingFile(mCurrentUpload.getOriginalStoragePath()); db.close(); // remove success notification, with a delay of 2 seconds NotificationDelayer.cancelWithDelay(mNotificationManager, R.string.uploader_upload_succeeded_ticker, 2000); } } }
From source file:org.telepatch.android.NotificationsController.java
public void processNewMessages(ArrayList<MessageObject> messageObjects, boolean isLast) { if (messageObjects.isEmpty()) { return;// w w w .ja v a2 s.c o m } boolean added = false; int oldCount = popupMessages.size(); HashMap<Long, Boolean> settingsCache = new HashMap<Long, Boolean>(); int popup = 0; for (MessageObject messageObject : messageObjects) { if (pushMessagesDict.containsKey(messageObject.messageOwner.id)) { continue; } long dialog_id = messageObject.getDialogId(); if (dialog_id == openned_dialog_id && ApplicationLoader.isScreenOn) { continue; } if (isPersonalMessage(messageObject)) { personal_count++; } added = true; Boolean value = settingsCache.get(dialog_id); boolean isChat = (int) dialog_id < 0; //TODO per ora disattivo i popup che non funzionano bene. //popup = (int)dialog_id == 0 ? 0 : preferences.getInt(isChat ? "popupGroup" : "popupAll", 0); if (value == null) { int notify_override = preferences.getInt("notify2_" + dialog_id, 0); value = !(notify_override == 2 || (!preferences.getBoolean("EnableAll", true) || isChat && !preferences.getBoolean("EnableGroup", true)) && notify_override == 0); settingsCache.put(dialog_id, value); } if (value) { if (popup != 0) { popupMessages.add(0, messageObject); } pushMessages.add(0, messageObject); pushMessagesDict.put(messageObject.messageOwner.id, messageObject); } } if (added) { notifyCheck = isLast; } if (!popupMessages.isEmpty() && oldCount != popupMessages.size()) { if (ApplicationLoader.mainInterfacePaused || !ApplicationLoader.isScreenOn) { MessageObject messageObject = messageObjects.get(0); if (popup == 3 || popup == 1 && ApplicationLoader.isScreenOn || popup == 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); } } } }
From source file:com.secupwn.aimsicd.service.CellTracker.java
/** * Description: Set or update the Detection/Status Notification * TODO: Need to add status HIGH (Orange) and SKULL (Black) * * Issues:/*from w w w. j a v a 2 s . com*/ * See: https://github.com/SecUpwN/Android-IMSI-Catcher-Detector/wiki/Status-Icons * and: https://github.com/SecUpwN/Android-IMSI-Catcher-Detector/issues/11#issuecomment-44670204 * * [ ] We need to standardize the "contentText" and "tickerText" format * * [ ] From #91: https://github.com/SecUpwN/Android-IMSI-Catcher-Detector/issues/91 * * Problem: * Having multiple notifications will cause an issue with * notifications themselves AND tickerText. It seems that the * most recent notification raised would overwrite any previous, * notification or tickerText. This results in loss of information * for any notification before the last one. * * Possible Solution: * Perhaps arranging a queue implementation to deal with text * being passed into tickerText only when any previous text has * been entirely displayed. * * Dependencies: Status.java, CellTracker.java, Icon.java ( + others?) * */ void setNotification() { String tickerText; String contentText = "Phone Type " + device.getPhoneType(); if (femtoDetected || typeZeroSmsDetected) { getApplication().setCurrentStatus(Status.DANGER, vibrateEnabled, vibrateMinThreatLevel); } else if (changedLAC) { getApplication().setCurrentStatus(Status.MEDIUM, vibrateEnabled, vibrateMinThreatLevel); contentText = context.getString(R.string.hostile_service_area_changing_lac_detected); } else if (emptyNeighborCellsList) { getApplication().setCurrentStatus(Status.MEDIUM, vibrateEnabled, vibrateMinThreatLevel); contentText = context.getString(R.string.cell_doesnt_provide_any_neighbors); } else if (cellIdNotInOpenDb) { getApplication().setCurrentStatus(Status.MEDIUM, vibrateEnabled, vibrateMinThreatLevel); contentText = context.getString(R.string.cell_id_doesnt_exist_in_db); } else if (trackingFemtocell || trackingCell || monitoringCell) { getApplication().setCurrentStatus(Status.OK, vibrateEnabled, vibrateMinThreatLevel); if (trackingFemtocell) { contentText = context.getString(R.string.femtocell_detection_active); } else if (trackingCell) { contentText = context.getString(R.string.cell_tracking_active); } if (monitoringCell) { contentText = context.getString(R.string.cell_monitoring_active); } else { getApplication().setCurrentStatus(Status.IDLE, vibrateEnabled, vibrateMinThreatLevel); } } else { getApplication().setCurrentStatus(Status.IDLE, vibrateEnabled, vibrateMinThreatLevel); } Status status = getApplication().getStatus(); switch (status) { case IDLE: // GRAY contentText = context.getString(R.string.phone_type) + device.getPhoneType(); tickerText = context.getResources().getString(R.string.app_name_short) + " " + context.getString(R.string.status_idle_description); break; case OK: // GREEN tickerText = context.getResources().getString(R.string.app_name_short) + " " + context.getString(R.string.status_ok_description); break; case MEDIUM: // YELLOW // Initialize tickerText as the app name string // See multiple detection comments above. tickerText = context.getResources().getString(R.string.app_name_short); if (changedLAC) { //Append changing LAC text contentText = context.getString(R.string.hostile_service_area_changing_lac_detected); tickerText += " - " + contentText; } else if (emptyNeighborCellsList) { //According to #264 contentText = context.getString(R.string.cell_doesnt_provide_any_neighbors); tickerText += " - " + contentText; } else if (cellIdNotInOpenDb) { //Append Cell ID not existing in external db text contentText = context.getString(R.string.cell_id_doesnt_exist_in_db); tickerText += " - " + contentText; } break; case DANGER: // RED tickerText = context.getResources().getString(R.string.app_name_short) + " - " + context.getString(R.string.alert_threat_detected); // Hmm, this is vague! if (femtoDetected) { contentText = context.getString(R.string.alert_femtocell_connection_detected); } else if (typeZeroSmsDetected) { contentText = context.getString(R.string.alert_silent_sms_detected); } break; default: tickerText = context.getResources().getString(R.string.main_app_name); break; } // TODO: Explanation (see above) Intent notificationIntent = new Intent(context, MainActivity.class); notificationIntent.putExtra("silent_sms", typeZeroSmsDetected); notificationIntent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_FROM_BACKGROUND); PendingIntent contentIntent = PendingIntent.getActivity(context, NOTIFICATION_ID, notificationIntent, PendingIntent.FLAG_CANCEL_CURRENT); String iconType = prefs.getString(context.getString(R.string.pref_ui_icons_key), "SENSE").toUpperCase(); int iconResId = Icon.getIcon(Icon.Type.valueOf(iconType), status); Bitmap largeIcon = BitmapFactory.decodeResource(context.getResources(), iconResId); int color = context.getResources().getColor(status.getColor()); Notification notification = new NotificationCompat.Builder(context).setSmallIcon(R.drawable.tower48) .setColor(color).setLargeIcon(largeIcon).setTicker(tickerText) .setContentTitle(context.getString(R.string.status) + " " + context.getString(status.getName())) .setContentInfo(context.getResources().getString(R.string.app_name_short)) .setContentText(contentText).setOngoing(true).setAutoCancel(false).setContentIntent(contentIntent) .build(); NotificationManagerCompat.from(context).notify(NOTIFICATION_ID, notification); }
From source file:me.cpwc.nibblegram.android.NotificationsController.java
public void processNewMessages(ArrayList<MessageObject> messageObjects, boolean isLast) { if (messageObjects.isEmpty()) { return;/*from www . j ava 2 s . c o m*/ } boolean added = false; int oldCount = popupMessages.size(); HashMap<Long, Boolean> settingsCache = new HashMap<Long, Boolean>(); SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Context.MODE_PRIVATE); int popup = 0; for (MessageObject messageObject : messageObjects) { if (pushMessagesDict.containsKey(messageObject.messageOwner.id)) { continue; } long dialog_id = messageObject.getDialogId(); if (dialog_id == openned_dialog_id && ApplicationLoader.isScreenOn) { continue; } 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 notify_override = preferences.getInt("notify2_" + dialog_id, 0); value = !(notify_override == 2 || (!preferences.getBoolean("EnableAll", true) || isChat && !preferences.getBoolean("EnableGroup", true)) && notify_override == 0); settingsCache.put(dialog_id, value); } if (value) { if (popup != 0) { popupMessages.add(0, messageObject); } pushMessages.add(0, messageObject); pushMessagesDict.put(messageObject.messageOwner.id, messageObject); } } if (added) { notifyCheck = isLast; } if (!popupMessages.isEmpty() && oldCount != popupMessages.size()) { if (ApplicationLoader.mainInterfacePaused || !ApplicationLoader.isScreenOn) { MessageObject messageObject = messageObjects.get(0); if (popup == 3 || popup == 1 && ApplicationLoader.isScreenOn || popup == 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); } } } }
From source file:com.yangtsaosoftware.pebblemessenger.services.PebbleCenter.java
private void dialNumber(String phoneNumber, boolean isSpeakon) { Context context = getApplicationContext(); AudioManager audioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE); Constants.log(TAG_NAME, String.format("Dial phone:%s", phoneNumber)); // ??//from w w w .j a v a2 s .c o m Intent callIntent = new Intent(Intent.ACTION_CALL); callIntent.setData(Uri.parse(String.format("tel:%s", phoneNumber))); callIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); callIntent.addFlags(Intent.FLAG_FROM_BACKGROUND); startActivity(callIntent); if (!(audioManager.isWiredHeadsetOn() || audioManager.isBluetoothA2dpOn())) { // 4.1??? 4.1??Permission Denial: not allowed to // send broadcast android.intent.action.HEADSET_PLUG from pid=1324, // uid=10017 // ??????android.permission.CALL_PRIVLEGED?????4.1??????????NULL?? Constants.log("speakerset", String.format("AudioManager before mode:%d speaker mod:%s", audioManager.getMode(), String.valueOf(audioManager.isSpeakerphoneOn()))); if (isSpeakon) { try { Thread.sleep(500); } catch (InterruptedException e) { Constants.log("speakerset", "Problem while sleeping"); } Constants.log("speakerset", String.format("AudioManager answer mode:%d speaker mod:%s", audioManager.getMode(), String.valueOf(audioManager.isSpeakerphoneOn()))); while (audioManager.getMode() != AudioManager.MODE_IN_CALL) { try { Thread.sleep(300); } catch (InterruptedException e) { Constants.log("speakerset", "Problem while sleeping"); } } // audioManager.setMicrophoneMute(true); audioManager.setSpeakerphoneOn(true); // audioManager.setMode(AudioManager.MODE_IN_CALL); Constants.log("speakerset", String.format("AudioManager set mode:%d speaker mod:%s", audioManager.getMode(), String.valueOf(audioManager.isSpeakerphoneOn()))); } } }
From source file:com.negaheno.android.NotificationsController.java
public void processNewMessages(ArrayList<MessageObject> messageObjects, boolean isLast) { if (messageObjects.isEmpty()) { return;//from w w w . j ava 2s . c om } boolean added = false; int oldCount = popupMessages.size(); HashMap<Long, Boolean> settingsCache = new HashMap<>(); SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Context.MODE_PRIVATE); int popup = 0; for (MessageObject messageObject : messageObjects) { if (pushMessagesDict.containsKey(messageObject.messageOwner.id)) { continue; } long dialog_id = messageObject.getDialogId(); if (dialog_id == openned_dialog_id && ApplicationLoader.isScreenOn) { continue; } 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 notify_override = preferences.getInt("notify2_" + dialog_id, 0); if (notify_override == 3) { int mute_until = preferences.getInt("notifyuntil_" + dialog_id, 0); if (mute_until >= ConnectionsManager.getInstance().getCurrentTime()) { notify_override = 2; } } value = !(notify_override == 2 || (!preferences.getBoolean("EnableAll", true) || isChat && !preferences.getBoolean("EnableGroup", true)) && notify_override == 0); settingsCache.put(dialog_id, value); } if (value) { if (popup != 0) { popupMessages.add(0, messageObject); } pushMessages.add(0, messageObject); pushMessagesDict.put(messageObject.messageOwner.id, messageObject); } } if (added) { notifyCheck = isLast; } if (!popupMessages.isEmpty() && oldCount != popupMessages.size() && !AndroidUtilities.needShowPasscode(false) && !UserConfig.isWaitingForPasscodeEnter) { if (ApplicationLoader.mainInterfacePaused || !ApplicationLoader.isScreenOn) { MessageObject messageObject = messageObjects.get(0); if (popup == 3 || popup == 1 && ApplicationLoader.isScreenOn || popup == 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); } } } }
From source file:org.hermes.android.NotificationsController.java
public void processNewMessages(ArrayList<MessageObject> messageObjects, boolean isLast) { if (messageObjects.isEmpty()) { return;// w ww. ja v a2 s . c om } boolean added = false; int oldCount = popupMessages.size(); HashMap<Long, Boolean> settingsCache = new HashMap<>(); SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Context.MODE_PRIVATE); int popup = 0; for (MessageObject messageObject : messageObjects) { if (pushMessagesDict.containsKey(messageObject.getId())) { 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 notify_override = preferences.getInt("notify2_" + dialog_id, 0); if (notify_override == 3) { int mute_until = preferences.getInt("notifyuntil_" + dialog_id, 0); if (mute_until >= ConnectionsManager.getInstance().getCurrentTime()) { notify_override = 2; } } value = !(notify_override == 2 || (!preferences.getBoolean("EnableAll", true) || isChat && !preferences.getBoolean("EnableGroup", true)) && notify_override == 0); settingsCache.put(dialog_id, value); } if (value) { if (popup != 0) { popupMessages.add(0, messageObject); } pushMessages.add(0, messageObject); pushMessagesDict.put(messageObject.getId(), messageObject); if (original_dialog_id != dialog_id) { pushDialogsOverrideMention.put(original_dialog_id, 1); } } } if (added) { notifyCheck = isLast; } if (!popupMessages.isEmpty() && oldCount != popupMessages.size() && !AndroidUtilities.needShowPasscode(false) && !UserConfig.isWaitingForPasscodeEnter) { if (ApplicationLoader.mainInterfacePaused || !ApplicationLoader.isScreenOn) { MessageObject messageObject = messageObjects.get(0); if (popup == 3 || popup == 1 && ApplicationLoader.isScreenOn || popup == 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); } } } }
From source file:org.vshgap.android.NotificationsController.java
public void processNewMessages(ArrayList<MessageObject> messageObjects, boolean isLast) { if (messageObjects.isEmpty()) { return;/*from ww w . j a va 2 s. co m*/ } boolean added = false; int oldCount = popupMessages.size(); HashMap<Long, Boolean> settingsCache = new HashMap<>(); SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Context.MODE_PRIVATE); int popup = 0; for (MessageObject messageObject : messageObjects) { if (pushMessagesDict.containsKey(messageObject.getId())) { 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) { popupMessages.add(0, messageObject); } delayedPushMessages.add(messageObject); pushMessages.add(0, messageObject); pushMessagesDict.put(messageObject.getId(), messageObject); if (original_dialog_id != dialog_id) { pushDialogsOverrideMention.put(original_dialog_id, 1); } } } if (added) { notifyCheck = isLast; } if (!popupMessages.isEmpty() && oldCount != popupMessages.size() && !AndroidUtilities.needShowPasscode(false) && !UserConfig.isWaitingForPasscodeEnter) { if (ApplicationLoader.mainInterfacePaused || !ApplicationLoader.isScreenOn) { MessageObject messageObject = messageObjects.get(0); if (popup == 3 || popup == 1 && ApplicationLoader.isScreenOn || popup == 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); } } } }
From source file:org.telegramsecureplus.android.NotificationsController.java
public void processNewMessages(ArrayList<MessageObject> messageObjects, boolean isLast) { if (messageObjects.isEmpty()) { return;//from w w w .ja v a 2 s. c o m } boolean added = false; int oldCount = popupMessages.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); if (pushMessagesDict.containsKey(messageObject.getId())) { 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) { popupMessages.add(0, messageObject); } delayedPushMessages.add(messageObject); pushMessages.add(0, messageObject); pushMessagesDict.put(messageObject.getId(), messageObject); if (original_dialog_id != dialog_id) { pushDialogsOverrideMention.put(original_dialog_id, 1); } } } if (added) { notifyCheck = isLast; } if (!popupMessages.isEmpty() && oldCount != popupMessages.size() && !AndroidUtilities.needShowPasscode(false) && !UserConfig.isWaitingForPasscodeEnter) { if (ApplicationLoader.mainInterfacePaused || !ApplicationLoader.isScreenOn) { MessageObject messageObject = messageObjects.get(0); if (popup == 3 || popup == 1 && ApplicationLoader.isScreenOn || popup == 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); } } } }