urbanairship-core/src/main/java/com/urbanairship/actions/ActionRegistry.java
public void registerDefaultActions(Context context) {
        try {
            XmlResourceParser parser = context.getResources().getXml(R.xml.ua_default_actions);

            while (parser.next() != XmlPullParser.END_DOCUMENT) {
                int tagType = parser.getEventType();
                String tagName = parser.getName();

                if (!(tagType == XmlPullParser.START_TAG && ACTION_ENTRY_TAG.equals(tagName))) {
                    continue;
                }

                String className = parser.getAttributeValue(null, CLASS_ATTRIBUTE);
                if (UAStringUtil.isEmpty(className)) {
                    Logger.error(ACTION_ENTRY_TAG + " must specify class attribute.");
                    continue;
                }
                
                Class<? extends Action> c;
                try {
                    c = Class.forName(className).asSubclass(Action.class);
                } catch (ClassNotFoundException e) {
                    Logger.error("Action class " + className + " not found. Skipping action registration.");
                    continue;
                }

                // Handle primary and secondary names.
                String actionName = parser.getAttributeValue(null, NAME_ATTRIBUTE);
                if (actionName == null) {
                    Logger.error(ACTION_ENTRY_TAG + " must specify name attribute.");
                    continue;
                }
                String altActionName = parser.getAttributeValue(null, ALT_NAME_ATTRIBUTE);
                String[] names = UAStringUtil.isEmpty(altActionName) ? new String[] { actionName } : new String[] { actionName, altActionName };
                Entry entry = registerAction(c, names);

                // Handle optional predicate class.
                String predicateClassName = parser.getAttributeValue(null, PREDICATE_ATTRIBUTE);
                if (predicateClassName == null) {
                    continue;
                }

                Predicate predicate;
                try {
                    predicate = Class.forName(predicateClassName).asSubclass(Predicate.class).newInstance();
                    entry.setPredicate(predicate);
                } catch (Exception e) {
                    Logger.error("Predicate class " + predicateClassName + " not found. Skipping predicate.");
                }
            }
        } catch (XmlPullParserException | IOException | Resources.NotFoundException | NullPointerException e) {
            // Note: NullPointerException can occur in rare circumstances further down the call stack
            Logger.error("Failed to parse ActionEntry:" + e.getMessage());
        }
    }
/**
     * Registers default actions using a resource file.
     *
     * @param context The application context.
     */
Registers default actions using a resource file.
@param context The application context.
Registers default actions using a resource file . @param context The application context .
public void registerDefaultActions(Context context) {
        try {
            XmlResourceParser parser = context.getResources().getXml(R.xml.ua_default_actions);
            while (parser.next() != XmlPullParser.END_DOCUMENT) {
                int tagType = parser.getEventType();
                String tagName = parser.getName();
                if (!(tagType == XmlPullParser.START_TAG && ACTION_ENTRY_TAG.equals(tagName))) {
                    continue;
                }
                String className = parser.getAttributeValue(null, CLASS_ATTRIBUTE);
                if (UAStringUtil.isEmpty(className)) {
                    Logger.error(ACTION_ENTRY_TAG + " must specify class attribute.");
                    continue;
                }
                Class<? extends Action> c;
                try {
                    c = Class.forName(className).asSubclass(Action.class);
                } catch (ClassNotFoundException e) {
                    Logger.error("Action class " + className + " not found. Skipping action registration.");
                    continue;
                }
                String actionName = parser.getAttributeValue(null, NAME_ATTRIBUTE);
                if (actionName == null) {
                    Logger.error(ACTION_ENTRY_TAG + " must specify name attribute.");
                    continue;
                }
                String altActionName = parser.getAttributeValue(null, ALT_NAME_ATTRIBUTE);
                String[] names = UAStringUtil.isEmpty(altActionName) ? new String[] { actionName } : new String[] { actionName, altActionName };
                Entry entry = registerAction(c, names);
                String predicateClassName = parser.getAttributeValue(null, PREDICATE_ATTRIBUTE);
                if (predicateClassName == null) {
                    continue;
                }
                Predicate predicate;
                try {
                    predicate = Class.forName(predicateClassName).asSubclass(Predicate.class).newInstance();
                    entry.setPredicate(predicate);
                } catch (Exception e) {
                    Logger.error("Predicate class " + predicateClassName + " not found. Skipping predicate.");
                }
            }
        } catch (XmlPullParserException | IOException | Resources.NotFoundException | NullPointerException e) {
            Logger.error("Failed to parse ActionEntry:" + e.getMessage());
        }
    }
public void registerDefaultActions ( Context context ) { try { XmlResourceParser parser = context . getResources ( ) . getXml ( R . xml . ua_default_actions ) ; while ( parser . next ( ) != XmlPullParser . END_DOCUMENT ) { int tagType = parser . getEventType ( ) ; String tagName = parser . getName ( ) ; if ( ! ( tagType == XmlPullParser . START_TAG && ACTION_ENTRY_TAG . equals ( tagName ) ) ) { continue ; } String className = parser . getAttributeValue ( null , CLASS_ATTRIBUTE ) ; if ( UAStringUtil . isEmpty ( className ) ) { Logger . error ( ACTION_ENTRY_TAG + " must specify class attribute." ) ; continue ; } Class < ? extends Action > c ; try { c = Class . forName ( className ) . asSubclass ( Action . class ) ; } catch ( ClassNotFoundException e ) { Logger . error ( "Action class " + className + " not found. Skipping action registration." ) ; continue ; } String actionName = parser . getAttributeValue ( null , NAME_ATTRIBUTE ) ; if ( actionName == null ) { Logger . error ( ACTION_ENTRY_TAG + " must specify name attribute." ) ; continue ; } String altActionName = parser . getAttributeValue ( null , ALT_NAME_ATTRIBUTE ) ; String [ ] names = UAStringUtil . isEmpty ( altActionName ) ? new String [ ] { actionName } : new String [ ] { actionName , altActionName } ; Entry entry = registerAction ( c , names ) ; String predicateClassName = parser . getAttributeValue ( null , PREDICATE_ATTRIBUTE ) ; if ( predicateClassName == null ) { continue ; } Predicate predicate ; try { predicate = Class . forName ( predicateClassName ) . asSubclass ( Predicate . class ) . newInstance ( ) ; entry . setPredicate ( predicate ) ; } catch ( Exception e ) { Logger . error ( "Predicate class " + predicateClassName + " not found. Skipping predicate." ) ; } } } catch ( XmlPullParserException | IOException | Resources . NotFoundException | NullPointerException e ) { Logger . error ( "Failed to parse ActionEntry:" + e . getMessage ( ) ) ; } }
Registers default actions using a resource file.
Registers default actions using a resource file .
// Handle primary and secondary names. // Handle optional predicate class. // Note: NullPointerException can occur in rare circumstances further down the call stack