Example usage for android.content Intent FLAG_ACTIVITY_NO_USER_ACTION

List of usage examples for android.content Intent FLAG_ACTIVITY_NO_USER_ACTION

Introduction

In this page you can find the example usage for android.content Intent FLAG_ACTIVITY_NO_USER_ACTION.

Prototype

int FLAG_ACTIVITY_NO_USER_ACTION

To view the source code for android.content Intent FLAG_ACTIVITY_NO_USER_ACTION.

Click Source Link

Document

If set, this flag will prevent the normal android.app.Activity#onUserLeaveHint callback from occurring on the current frontmost activity before it is paused as the newly-started activity is brought to the front.

Usage

From source file:org.telepatch.android.NotificationsController.java

public void processNewMessages(ArrayList<MessageObject> messageObjects, boolean isLast) {
    if (messageObjects.isEmpty()) {
        return;/* w  w w .java  2 s . co  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:me.cpwc.nibblegram.android.NotificationsController.java

public void processNewMessages(ArrayList<MessageObject> messageObjects, boolean isLast) {
    if (messageObjects.isEmpty()) {
        return;//from  ww  w.j a v a2 s  . c om
    }
    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.negaheno.android.NotificationsController.java

public void processNewMessages(ArrayList<MessageObject> messageObjects, boolean isLast) {
    if (messageObjects.isEmpty()) {
        return;//from  ww w  .  j  ava  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 (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;/*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 (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 w ww .j a v a  2 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 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 ww  w  .  j av  a  2 s  .com
    }
    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);
            }
        }
    }
}