urbanairship-core/src/main/java/com/urbanairship/CoreReceiver.java
private void runActions(@NonNull Context context, @Nullable final Map<String, ActionValue> actions,
                            final int situation, @Nullable final Bundle metadata, @NonNull final Runnable callback) {

        if (actions == null || actions.isEmpty()) {
            callback.run();
            return;
        }

        if (ActivityMonitor.shared(context).isAppForegrounded() || situation == Action.SITUATION_FOREGROUND_NOTIFICATION_ACTION_BUTTON || situation == Action.SITUATION_PUSH_OPENED) {
            try {
                ActionService.runActions(context, actions, situation, metadata);
                callback.run();
                return;
            } catch (SecurityException | IllegalStateException e) {
                Logger.error("Unable to start action service.", e);
            }
        }

        // Fallback to running actions in the executor
        executor.execute(new Runnable() {
            @Override
            public void run() {
                for (Map.Entry<String, ActionValue> entry : actions.entrySet()) {
                    ActionRunRequest.createRequest(entry.getKey())
                            .setMetadata(metadata)
                            .setSituation(situation)
                            .setValue(entry.getValue())
                            .runSync();
                }

                callback.run();
            }
        });
    }
/**
     * Helper method to run the actions.
     *
     * @param context The context.
     * @param actions The actions payload.
     * @param situation The situation.
     * @param metadata The metadata.
     * @param callback Callback when finished.
     */
Helper method to run the actions.
@param context The context.
@param actions The actions payload.
@param situation The situation.
@param metadata The metadata.
@param callback Callback when finished.
Helper method to run the actions . @param context The context . @param actions The actions payload . @param situation The situation . @param metadata The metadata . @param callback Callback when finished .
private void runActions(@NonNull Context context, @Nullable final Map<String, ActionValue> actions,
                            final int situation, @Nullable final Bundle metadata, @NonNull final Runnable callback) {
        if (actions == null || actions.isEmpty()) {
            callback.run();
            return;
        }
        if (ActivityMonitor.shared(context).isAppForegrounded() || situation == Action.SITUATION_FOREGROUND_NOTIFICATION_ACTION_BUTTON || situation == Action.SITUATION_PUSH_OPENED) {
            try {
                ActionService.runActions(context, actions, situation, metadata);
                callback.run();
                return;
            } catch (SecurityException | IllegalStateException e) {
                Logger.error("Unable to start action service.", e);
            }
        }
        executor.execute(new Runnable() {
            @Override
            public void run() {
                for (Map.Entry<String, ActionValue> entry : actions.entrySet()) {
                    ActionRunRequest.createRequest(entry.getKey())
                            .setMetadata(metadata)
                            .setSituation(situation)
                            .setValue(entry.getValue())
                            .runSync();
                }
                callback.run();
            }
        });
    }
private void runActions ( @ NonNull Context context , @ Nullable final Map < String , ActionValue > actions , final int situation , @ Nullable final Bundle metadata , @ NonNull final Runnable callback ) { if ( actions == null || actions . isEmpty ( ) ) { callback . run ( ) ; return ; } if ( ActivityMonitor . shared ( context ) . isAppForegrounded ( ) || situation == Action . SITUATION_FOREGROUND_NOTIFICATION_ACTION_BUTTON || situation == Action . SITUATION_PUSH_OPENED ) { try { ActionService . runActions ( context , actions , situation , metadata ) ; callback . run ( ) ; return ; } catch ( SecurityException | IllegalStateException e ) { Logger . error ( "Unable to start action service." , e ) ; } } executor . execute ( new Runnable ( ) { @ Override public void run ( ) { for ( Map . Entry < String , ActionValue > entry : actions . entrySet ( ) ) { ActionRunRequest . createRequest ( entry . getKey ( ) ) . setMetadata ( metadata ) . setSituation ( situation ) . setValue ( entry . getValue ( ) ) . runSync ( ) ; } callback . run ( ) ; } } ) ; }
Helper method to run the actions.
Helper method to run the actions .
// Fallback to running actions in the executor