android.content.res.XmlResourceParser#getAttributeIntValue()源码实例Demo

下面列出了android.content.res.XmlResourceParser#getAttributeIntValue() 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: ACDD   文件: PackageLite.java
/**
 * parser ManifestAttribute such package name and so on
 * @param xmlResourceParser
 * @param mPackageLite
 */
private static void parserManifestAttribute(
        XmlResourceParser xmlResourceParser, PackageLite mPackageLite) {
    for (int i = 0; i < xmlResourceParser.getAttributeCount(); i++) {
        String value = xmlResourceParser.getAttributeName(i);

        if (value.equalsIgnoreCase("package")) {
            mPackageLite.packageName = xmlResourceParser
                    .getAttributeValue(i);

        }
        if (value.equals("versionCode")) {
            mPackageLite.versionCode = xmlResourceParser
                    .getAttributeIntValue(i, 0);

        } else if (value.equals("versionName")) {
            mPackageLite.versionName = xmlResourceParser
                    .getAttributeValue(i);

        }

    }
}
 
源代码2 项目: tilt-game-android   文件: LevelVO.java
public static LevelVO createFromXML (XmlResourceParser parser, String levelPackage, String controllerPackge) {
    LevelVO levelVO = new LevelVO();
    levelVO.id = (long)parser.getAttributeIntValue(null, "id", 0);
    levelVO.levelClass = levelPackage + parser.getAttributeValue(null, "levelclass");
    levelVO.controllerClass = controllerPackge + parser.getAttributeValue(null, "controllerclass");
    levelVO.difficulty = parser.getAttributeIntValue(null, "difficulty", 0);
    levelVO.duration = parser.getAttributeIntValue(null, "duration", 25);

    return levelVO;
}
 
源代码3 项目: tilt-game-android   文件: FrameVO.java
public FrameVO(XmlResourceParser parser) {
	int x, y, width, height;

	x = parser.getAttributeIntValue(null, "x", 0);
	y = parser.getAttributeIntValue(null, "y", 0);
	width = parser.getAttributeIntValue(null, "width", 0);
	height = parser.getAttributeIntValue(null, "height", 0);
	_bounds = new Rect(x, y, x + width, y + height);

	x = -parser.getAttributeIntValue(null, "frameX", 0);
	y = -parser.getAttributeIntValue(null, "frameY", 0);
	_frame = new Rect(x, y, x + width, y + height);

	_rotated = parser.getAttributeBooleanValue(null, "rotated", false);
}
 
源代码4 项目: FairEmail   文件: EmailProvider.java
static List<EmailProvider> loadProfiles(Context context) {
    List<EmailProvider> result = null;
    try {
        EmailProvider provider = null;
        XmlResourceParser xml = context.getResources().getXml(R.xml.providers);
        int eventType = xml.getEventType();
        while (eventType != XmlPullParser.END_DOCUMENT) {
            if (eventType == XmlPullParser.START_TAG) {
                String name = xml.getName();
                if ("providers".equals(name))
                    result = new ArrayList<>();
                else if ("provider".equals(name)) {
                    provider = new EmailProvider();
                    provider.id = xml.getAttributeValue(null, "id");
                    provider.name = xml.getAttributeValue(null, "name");
                    String domain = xml.getAttributeValue(null, "domain");
                    if (domain != null)
                        provider.domain = Arrays.asList(domain.split(","));
                    provider.order = xml.getAttributeIntValue(null, "order", Integer.MAX_VALUE);
                    provider.keepalive = xml.getAttributeIntValue(null, "keepalive", 0);
                    provider.partial = xml.getAttributeBooleanValue(null, "partial", true);
                    provider.useip = xml.getAttributeBooleanValue(null, "useip", true);
                    provider.appPassword = xml.getAttributeBooleanValue(null, "appPassword", false);
                    provider.link = xml.getAttributeValue(null, "link");
                    provider.type = xml.getAttributeValue(null, "type");
                    String user = xml.getAttributeValue(null, "user");
                    if ("local".equals(user))
                        provider.user = UserType.LOCAL;
                    else if ("email".equals(user))
                        provider.user = UserType.EMAIL;
                } else if ("imap".equals(name)) {
                    provider.imap.host = xml.getAttributeValue(null, "host");
                    provider.imap.port = xml.getAttributeIntValue(null, "port", 0);
                    provider.imap.starttls = xml.getAttributeBooleanValue(null, "starttls", false);
                } else if ("smtp".equals(name)) {
                    provider.smtp.host = xml.getAttributeValue(null, "host");
                    provider.smtp.port = xml.getAttributeIntValue(null, "port", 0);
                    provider.smtp.starttls = xml.getAttributeBooleanValue(null, "starttls", false);
                } else if ("oauth".equals(name)) {
                    provider.oauth = new OAuth();
                    provider.oauth.enabled = xml.getAttributeBooleanValue(null, "enabled", false);
                    provider.oauth.askAccount = xml.getAttributeBooleanValue(null, "askAccount", false);
                    provider.oauth.clientId = xml.getAttributeValue(null, "clientId");
                    provider.oauth.clientSecret = xml.getAttributeValue(null, "clientSecret");
                    provider.oauth.scopes = xml.getAttributeValue(null, "scopes").split(",");
                    provider.oauth.authorizationEndpoint = xml.getAttributeValue(null, "authorizationEndpoint");
                    provider.oauth.tokenEndpoint = xml.getAttributeValue(null, "tokenEndpoint");
                    provider.oauth.redirectUri = xml.getAttributeValue(null, "redirectUri");
                } else
                    throw new IllegalAccessException(name);
            } else if (eventType == XmlPullParser.END_TAG) {
                if ("provider".equals(xml.getName())) {
                    result.add(provider);
                    provider = null;
                }
            }

            eventType = xml.next();
        }
    } catch (Throwable ex) {
        Log.e(ex);
    }
    final Collator collator = Collator.getInstance(Locale.getDefault());
    collator.setStrength(Collator.SECONDARY); // Case insensitive, process accents etc

    Collections.sort(result, new Comparator<EmailProvider>() {
        @Override
        public int compare(EmailProvider p1, EmailProvider p2) {
            int o = Integer.compare(p1.order, p2.order);
            if (o == 0)
                return collator.compare(p1.name, p2.name);
            else
                return o;
        }
    });

    return result;
}
 
源代码5 项目: CSipSimple   文件: ActionBarSherlockCompat.java
private static int loadUiOptionsFromManifest(Activity activity) {
    int uiOptions = 0;
    try {
        final String thisPackage = activity.getClass().getName();
        if (ActionBarSherlock.DEBUG) Log.i(TAG, "Parsing AndroidManifest.xml for " + thisPackage);

        final String packageName = activity.getApplicationInfo().packageName;
        final AssetManager am = activity.createPackageContext(packageName, 0).getAssets();
        final XmlResourceParser xml = am.openXmlResourceParser("AndroidManifest.xml");

        int eventType = xml.getEventType();
        while (eventType != XmlPullParser.END_DOCUMENT) {
            if (eventType == XmlPullParser.START_TAG) {
                String name = xml.getName();

                if ("application".equals(name)) {
                    //Check if the <application> has the attribute
                    if (ActionBarSherlock.DEBUG) Log.d(TAG, "Got <application>");

                    for (int i = xml.getAttributeCount() - 1; i >= 0; i--) {
                        if (ActionBarSherlock.DEBUG) Log.d(TAG, xml.getAttributeName(i) + ": " + xml.getAttributeValue(i));

                        if ("uiOptions".equals(xml.getAttributeName(i))) {
                            uiOptions = xml.getAttributeIntValue(i, 0);
                            break; //out of for loop
                        }
                    }
                } else if ("activity".equals(name)) {
                    //Check if the <activity> is us and has the attribute
                    if (ActionBarSherlock.DEBUG) Log.d(TAG, "Got <activity>");
                    Integer activityUiOptions = null;
                    String activityPackage = null;
                    boolean isOurActivity = false;

                    for (int i = xml.getAttributeCount() - 1; i >= 0; i--) {
                        if (ActionBarSherlock.DEBUG) Log.d(TAG, xml.getAttributeName(i) + ": " + xml.getAttributeValue(i));

                        //We need both uiOptions and name attributes
                        String attrName = xml.getAttributeName(i);
                        if ("uiOptions".equals(attrName)) {
                            activityUiOptions = xml.getAttributeIntValue(i, 0);
                        } else if ("name".equals(attrName)) {
                            activityPackage = cleanActivityName(packageName, xml.getAttributeValue(i));
                            if (!thisPackage.equals(activityPackage)) {
                                break; //out of for loop
                            }
                            isOurActivity = true;
                        }

                        //Make sure we have both attributes before processing
                        if ((activityUiOptions != null) && (activityPackage != null)) {
                            //Our activity, uiOptions specified, override with our value
                            uiOptions = activityUiOptions.intValue();
                        }
                    }
                    if (isOurActivity) {
                        //If we matched our activity but it had no logo don't
                        //do any more processing of the manifest
                        break;
                    }
                }
            }
            eventType = xml.nextToken();
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
    if (ActionBarSherlock.DEBUG) Log.i(TAG, "Returning " + Integer.toHexString(uiOptions));
    return uiOptions;
}
 
源代码6 项目: brailleback   文件: TableList.java
private void parseTable(XmlResourceParser p) {
    Locale locale = parseLocale(p.getAttributeValue(null, ATTR_LOCALE));
    if (locale == null) {
        throw new RuntimeException(p.getPositionDescription()
                + ": Locale must be specified");
    }
    int dots = p.getAttributeIntValue(null, ATTR_DOTS, -1);
    int grade = p.getAttributeIntValue(null, ATTR_GRADE, -1);
    if (dots < 0 && grade < 0) {
        throw new RuntimeException(p.getPositionDescription()
                + ": neither dots nor grade was specified");
    }
    if (grade >= 0 && dots < 0) {
        dots = 6;
    }
    switch (dots) {
        case 6:
            if (grade < 0) {
                grade = 1;
            }
            break;
        case 8:
            if (grade >= 0) {
                throw new RuntimeException(p.getPositionDescription()
                        + ": grade must not be specified for 8 dot "
                        + "braille");
            }
            break;
        default:
            throw new RuntimeException(p.getPositionDescription()
                    + ": dots must be either 6 or 8");
    }
    String id = p.getAttributeValue(null, ATTR_ID);
    if (id == null) {
        throw new RuntimeException(p.getPositionDescription()
                + ": missing id attribute");
    }
    String variant = p.getAttributeValue(null, ATTR_VARIANT);
    String fileName = p.getAttributeValue(null, ATTR_FILE_NAME);
    if (fileName == null) {
        throw new RuntimeException(p.getPositionDescription()
                + ": missing fileName attribute");
    }
    mTableInfos.add(new TableInfo(locale, dots == 8, grade, id, variant));
    mTableFileNames.put(id, fileName);
    if (DBG) {
        Log.v(LOG_TAG, String.format("Table %s: locale=%s, dots=%d, "
                        + "grade=%d, variant=%s,fileName=%s",
                        id, locale.getDisplayName(), dots, grade,
                        variant, fileName));
    }
}
 
源代码7 项目: WirelessHid   文件: Keyboard.java
private LinearLayout parseKeyLayout(Context context, XmlResourceParser xmlParser)
        throws XmlPullParserException, IOException {
    LinearLayout linearLayout = new LinearLayout(context);
    linearLayout.setLayoutParams(new LayoutParams(
            xmlParser.getAttributeIntValue(null, "width", LayoutParams.MATCH_PARENT),
            xmlParser.getAttributeIntValue(null, "height", 0),
            xmlParser.getAttributeFloatValue(null, "weight", 1.0f)));
    linearLayout.setOrientation(xmlParser.getAttributeIntValue(null, "orientation",
            LinearLayout.HORIZONTAL));

    String tag;
    do {
        xmlParser.next();
        tag = xmlParser.getName();

        if (xmlParser.getEventType() == XmlResourceParser.START_TAG) {
            if (tag.equals(XML_TAG_LAYOUT)) {
                linearLayout.addView(parseKeyLayout(context, xmlParser));
            } else if (tag.equals(XML_TAG_KEY)) {
                Key.KeyAttributes attrs = new Key.KeyAttributes();
                attrs.keyFunction = getStringAttributeValue(xmlParser, "keyFunc", "");
                attrs.mainLabel = getStringAttributeValue(xmlParser, "keyLabel", "");
                attrs.shiftLabel = getStringAttributeValue(xmlParser, "shiftLabel", "");
                attrs.keyCode = xmlParser.getAttributeIntValue(null, "keyCode", 0);

                Key key = new Key(context, attrs);
                key.setLayoutParams(new LayoutParams(
                        xmlParser.getAttributeIntValue(null, "width", 0),
                        xmlParser.getAttributeIntValue(null, "height",
                                LayoutParams.MATCH_PARENT),
                        xmlParser.getAttributeFloatValue(null, "weight", 1)));
                key.setVisibility(xmlParser.getAttributeBooleanValue(null, "visible", true) ?
                    VISIBLE : INVISIBLE);
                key.setKeyListener(this);

                if (attrs.shiftLabel != null & attrs.shiftLabel.length() > 0) {
                    mKeysWithShiftLabel.add(key);
                }

                linearLayout.addView(key);
            }
        }
    } while (xmlParser.getEventType() != XmlResourceParser.END_TAG
            || !tag.equals(XML_TAG_LAYOUT));

    return linearLayout;
}
 
源代码8 项目: ReminderDatePicker   文件: TimeSpinner.java
@Override
protected @Nullable TwinTextItem parseItemFromXmlTag(@NonNull XmlResourceParser parser) {
    if(!parser.getName().equals(XML_TAG_TIMEITEM)) {
        Log.d("TimeSpinner", "Unknown xml tag name: " + parser.getName());
        return null;
    }

    // parse the TimeItem, possible values are
    String text = null;
    @StringRes int textResource = NO_ID, id = NO_ID;
    int hour = 0, minute = 0;
    for(int i=parser.getAttributeCount()-1; i>=0; i--) {
        String attrName = parser.getAttributeName(i);
        switch (attrName) {
            case XML_ATTR_ID:
                id = parser.getIdAttributeResourceValue(NO_ID);
                break;
            case XML_ATTR_TEXT:
                text = parser.getAttributeValue(i);
                // try to get a resource value, the string is retrieved below
                if(text != null && text.startsWith("@"))
                    textResource = parser.getAttributeResourceValue(i, NO_ID);
                break;

            case XML_ATTR_ABSHOUR:
                hour = parser.getAttributeIntValue(i, -1);
                break;
            case XML_ATTR_ABSMINUTE:
                minute = parser.getAttributeIntValue(i, -1);
                break;

            case XML_ATTR_RELHOUR:
                hour += parser.getAttributeIntValue(i, 0);
                break;
            case XML_ATTR_RELMINUTE:
                minute += parser.getAttributeIntValue(i, 0);
                break;
            default:
                Log.d("TimeSpinner", "Skipping unknown attribute tag parsing xml resource: "
                        + attrName + ", maybe a typo?");
        }
    }// end for attr

    // now construct the time item from the attributes
    if(textResource != NO_ID)
        text = getResources().getString(textResource);

    // when no text is given, format the date to have at least something to show
    if(text == null || text.equals(""))
        text = formatTime(hour, minute);

    return new TimeItem(text, formatTime(hour, minute), hour, minute, id);
}
 
源代码9 项目: ReminderDatePicker   文件: DateSpinner.java
@Override
protected @Nullable TwinTextItem parseItemFromXmlTag(@NonNull XmlResourceParser parser) {
    if(!parser.getName().equals(XML_TAG_DATEITEM)) {
        Log.d("DateSpinner", "Unknown xml tag name: " + parser.getName());
        return null;
    }

    // parse the DateItem, possible values are
    String text = null;
    @StringRes int textResource = NO_ID, id = NO_ID;
    Calendar date = Calendar.getInstance();
    for(int i=parser.getAttributeCount()-1; i>=0; i--) {
        String attrName = parser.getAttributeName(i);
        switch (attrName) {
            case XML_ATTR_ID:
                id = parser.getIdAttributeResourceValue(NO_ID);
                break;
            case XML_ATTR_TEXT:
                text = parser.getAttributeValue(i);
                // try to get a resource value, the string is retrieved below
                if(text != null && text.startsWith("@"))
                    textResource = parser.getAttributeResourceValue(i, NO_ID);
                break;

            case XML_ATTR_ABSDAYOFYEAR:
                final int absDayOfYear = parser.getAttributeIntValue(i, -1);
                if(absDayOfYear > 0)
                    date.set(Calendar.DAY_OF_YEAR, absDayOfYear);
                break;
            case XML_ATTR_ABSDAYOFMONTH:
                final int absDayOfMonth = parser.getAttributeIntValue(i, -1);
                if(absDayOfMonth > 0)
                    date.set(Calendar.DAY_OF_MONTH, absDayOfMonth);
                break;
            case XML_ATTR_ABSMONTH:
                final int absMonth = parser.getAttributeIntValue(i, -1);
                if(absMonth >= 0)
                    date.set(Calendar.MONTH, absMonth);
                break;
            case XML_ATTR_ABSYEAR:
                final int absYear = parser.getAttributeIntValue(i, -1);
                if(absYear >= 0)
                    date.set(Calendar.YEAR, absYear);
                break;

            case XML_ATTR_RELDAY:
                final int relDay = parser.getAttributeIntValue(i, 0);
                date.add(Calendar.DAY_OF_YEAR, relDay);
                break;
            case XML_ATTR_RELMONTH:
                final int relMonth = parser.getAttributeIntValue(i, 0);
                date.add(Calendar.MONTH, relMonth);
                break;
            case XML_ATTR_RELYEAR:
                final int relYear = parser.getAttributeIntValue(i, 0);
                date.add(Calendar.YEAR, relYear);
                break;
            default:
                Log.d("DateSpinner", "Skipping unknown attribute tag parsing xml resource: "
                        + attrName + ", maybe a typo?");
        }
    }// end for attr

    // now construct the date item from the attributes

    // check if we got a textResource earlier and parse that string together with the weekday
    if(textResource != NO_ID)
        text = getWeekDay(date.get(Calendar.DAY_OF_WEEK), textResource);

    // when no text is given, format the date to have at least something to show
    if(text == null || text.equals(""))
        text = formatDate(date);

    return new DateItem(text, date, id);
}
 
源代码10 项目: android-apps   文件: ActionBarSherlockCompat.java
private static int loadUiOptionsFromManifest(Activity activity) {
    int uiOptions = 0;
    try {
        final String thisPackage = activity.getClass().getName();
        if (DEBUG) Log.i(TAG, "Parsing AndroidManifest.xml for " + thisPackage);

        final String packageName = activity.getApplicationInfo().packageName;
        final AssetManager am = activity.createPackageContext(packageName, 0).getAssets();
        final XmlResourceParser xml = am.openXmlResourceParser("AndroidManifest.xml");

        int eventType = xml.getEventType();
        while (eventType != XmlPullParser.END_DOCUMENT) {
            if (eventType == XmlPullParser.START_TAG) {
                String name = xml.getName();

                if ("application".equals(name)) {
                    //Check if the <application> has the attribute
                    if (DEBUG) Log.d(TAG, "Got <application>");

                    for (int i = xml.getAttributeCount() - 1; i >= 0; i--) {
                        if (DEBUG) Log.d(TAG, xml.getAttributeName(i) + ": " + xml.getAttributeValue(i));

                        if ("uiOptions".equals(xml.getAttributeName(i))) {
                            uiOptions = xml.getAttributeIntValue(i, 0);
                            break; //out of for loop
                        }
                    }
                } else if ("activity".equals(name)) {
                    //Check if the <activity> is us and has the attribute
                    if (DEBUG) Log.d(TAG, "Got <activity>");
                    Integer activityUiOptions = null;
                    String activityPackage = null;
                    boolean isOurActivity = false;

                    for (int i = xml.getAttributeCount() - 1; i >= 0; i--) {
                        if (DEBUG) Log.d(TAG, xml.getAttributeName(i) + ": " + xml.getAttributeValue(i));

                        //We need both uiOptions and name attributes
                        String attrName = xml.getAttributeName(i);
                        if ("uiOptions".equals(attrName)) {
                            activityUiOptions = xml.getAttributeIntValue(i, 0);
                        } else if ("name".equals(attrName)) {
                            activityPackage = cleanActivityName(packageName, xml.getAttributeValue(i));
                            if (!thisPackage.equals(activityPackage)) {
                                break; //out of for loop
                            }
                            isOurActivity = true;
                        }

                        //Make sure we have both attributes before processing
                        if ((activityUiOptions != null) && (activityPackage != null)) {
                            //Our activity, uiOptions specified, override with our value
                            uiOptions = activityUiOptions.intValue();
                        }
                    }
                    if (isOurActivity) {
                        //If we matched our activity but it had no logo don't
                        //do any more processing of the manifest
                        break;
                    }
                }
            }
            eventType = xml.nextToken();
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
    if (DEBUG) Log.i(TAG, "Returning " + Integer.toHexString(uiOptions));
    return uiOptions;
}
 
源代码11 项目: zen4android   文件: ActionBarSherlockCompat.java
private static int loadUiOptionsFromManifest(Activity activity) {
    int uiOptions = 0;
    try {
        final String thisPackage = activity.getClass().getName();
        if (ActionBarSherlock.DEBUG) Log.i(TAG, "Parsing AndroidManifest.xml for " + thisPackage);

        final String packageName = activity.getApplicationInfo().packageName;
        final AssetManager am = activity.createPackageContext(packageName, 0).getAssets();
        final XmlResourceParser xml = am.openXmlResourceParser("AndroidManifest.xml");

        int eventType = xml.getEventType();
        while (eventType != XmlPullParser.END_DOCUMENT) {
            if (eventType == XmlPullParser.START_TAG) {
                String name = xml.getName();

                if ("application".equals(name)) {
                    //Check if the <application> has the attribute
                    if (ActionBarSherlock.DEBUG) Log.d(TAG, "Got <application>");

                    for (int i = xml.getAttributeCount() - 1; i >= 0; i--) {
                        if (ActionBarSherlock.DEBUG) Log.d(TAG, xml.getAttributeName(i) + ": " + xml.getAttributeValue(i));

                        if ("uiOptions".equals(xml.getAttributeName(i))) {
                            uiOptions = xml.getAttributeIntValue(i, 0);
                            break; //out of for loop
                        }
                    }
                } else if ("activity".equals(name)) {
                    //Check if the <activity> is us and has the attribute
                    if (ActionBarSherlock.DEBUG) Log.d(TAG, "Got <activity>");
                    Integer activityUiOptions = null;
                    String activityPackage = null;
                    boolean isOurActivity = false;

                    for (int i = xml.getAttributeCount() - 1; i >= 0; i--) {
                        if (ActionBarSherlock.DEBUG) Log.d(TAG, xml.getAttributeName(i) + ": " + xml.getAttributeValue(i));

                        //We need both uiOptions and name attributes
                        String attrName = xml.getAttributeName(i);
                        if ("uiOptions".equals(attrName)) {
                            activityUiOptions = xml.getAttributeIntValue(i, 0);
                        } else if ("name".equals(attrName)) {
                            activityPackage = cleanActivityName(packageName, xml.getAttributeValue(i));
                            if (!thisPackage.equals(activityPackage)) {
                                break; //out of for loop
                            }
                            isOurActivity = true;
                        }

                        //Make sure we have both attributes before processing
                        if ((activityUiOptions != null) && (activityPackage != null)) {
                            //Our activity, uiOptions specified, override with our value
                            uiOptions = activityUiOptions.intValue();
                        }
                    }
                    if (isOurActivity) {
                        //If we matched our activity but it had no logo don't
                        //do any more processing of the manifest
                        break;
                    }
                }
            }
            eventType = xml.nextToken();
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
    if (ActionBarSherlock.DEBUG) Log.i(TAG, "Returning " + Integer.toHexString(uiOptions));
    return uiOptions;
}
 
源代码12 项目: zhangshangwuda   文件: ActionBarSherlockCompat.java
private static int loadUiOptionsFromManifest(Activity activity) {
    int uiOptions = 0;
    try {
        final String thisPackage = activity.getClass().getName();
        if (ActionBarSherlock.DEBUG) Log.i(TAG, "Parsing AndroidManifest.xml for " + thisPackage);

        final String packageName = activity.getApplicationInfo().packageName;
        final AssetManager am = activity.createPackageContext(packageName, 0).getAssets();
        final XmlResourceParser xml = am.openXmlResourceParser("AndroidManifest.xml");

        int eventType = xml.getEventType();
        while (eventType != XmlPullParser.END_DOCUMENT) {
            if (eventType == XmlPullParser.START_TAG) {
                String name = xml.getName();

                if ("application".equals(name)) {
                    //Check if the <application> has the attribute
                    if (ActionBarSherlock.DEBUG) Log.d(TAG, "Got <application>");

                    for (int i = xml.getAttributeCount() - 1; i >= 0; i--) {
                        if (ActionBarSherlock.DEBUG) Log.d(TAG, xml.getAttributeName(i) + ": " + xml.getAttributeValue(i));

                        if ("uiOptions".equals(xml.getAttributeName(i))) {
                            uiOptions = xml.getAttributeIntValue(i, 0);
                            break; //out of for loop
                        }
                    }
                } else if ("activity".equals(name)) {
                    //Check if the <activity> is us and has the attribute
                    if (ActionBarSherlock.DEBUG) Log.d(TAG, "Got <activity>");
                    Integer activityUiOptions = null;
                    String activityPackage = null;
                    boolean isOurActivity = false;

                    for (int i = xml.getAttributeCount() - 1; i >= 0; i--) {
                        if (ActionBarSherlock.DEBUG) Log.d(TAG, xml.getAttributeName(i) + ": " + xml.getAttributeValue(i));

                        //We need both uiOptions and name attributes
                        String attrName = xml.getAttributeName(i);
                        if ("uiOptions".equals(attrName)) {
                            activityUiOptions = xml.getAttributeIntValue(i, 0);
                        } else if ("name".equals(attrName)) {
                            activityPackage = cleanActivityName(packageName, xml.getAttributeValue(i));
                            if (!thisPackage.equals(activityPackage)) {
                                break; //out of for loop
                            }
                            isOurActivity = true;
                        }

                        //Make sure we have both attributes before processing
                        if ((activityUiOptions != null) && (activityPackage != null)) {
                            //Our activity, uiOptions specified, override with our value
                            uiOptions = activityUiOptions.intValue();
                        }
                    }
                    if (isOurActivity) {
                        //If we matched our activity but it had no logo don't
                        //do any more processing of the manifest
                        break;
                    }
                }
            }
            eventType = xml.nextToken();
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
    if (ActionBarSherlock.DEBUG) Log.i(TAG, "Returning " + Integer.toHexString(uiOptions));
    return uiOptions;
}
 
private static int loadUiOptionsFromManifest(Activity activity) {
    int uiOptions = 0;
    try {
        final String thisPackage = activity.getClass().getName();
        if (ActionBarSherlock.DEBUG) Log.i(TAG, "Parsing AndroidManifest.xml for " + thisPackage);

        final String packageName = activity.getApplicationInfo().packageName;
        final AssetManager am = activity.createPackageContext(packageName, 0).getAssets();
        final XmlResourceParser xml = am.openXmlResourceParser("AndroidManifest.xml");

        int eventType = xml.getEventType();
        while (eventType != XmlPullParser.END_DOCUMENT) {
            if (eventType == XmlPullParser.START_TAG) {
                String name = xml.getName();

                if ("application".equals(name)) {
                    //Check if the <application> has the attribute
                    if (ActionBarSherlock.DEBUG) Log.d(TAG, "Got <application>");

                    for (int i = xml.getAttributeCount() - 1; i >= 0; i--) {
                        if (ActionBarSherlock.DEBUG) Log.d(TAG, xml.getAttributeName(i) + ": " + xml.getAttributeValue(i));

                        if ("uiOptions".equals(xml.getAttributeName(i))) {
                            uiOptions = xml.getAttributeIntValue(i, 0);
                            break; //out of for loop
                        }
                    }
                } else if ("activity".equals(name)) {
                    //Check if the <activity> is us and has the attribute
                    if (ActionBarSherlock.DEBUG) Log.d(TAG, "Got <activity>");
                    Integer activityUiOptions = null;
                    String activityPackage = null;
                    boolean isOurActivity = false;

                    for (int i = xml.getAttributeCount() - 1; i >= 0; i--) {
                        if (ActionBarSherlock.DEBUG) Log.d(TAG, xml.getAttributeName(i) + ": " + xml.getAttributeValue(i));

                        //We need both uiOptions and name attributes
                        String attrName = xml.getAttributeName(i);
                        if ("uiOptions".equals(attrName)) {
                            activityUiOptions = xml.getAttributeIntValue(i, 0);
                        } else if ("name".equals(attrName)) {
                            activityPackage = cleanActivityName(packageName, xml.getAttributeValue(i));
                            if (!thisPackage.equals(activityPackage)) {
                                break; //out of for loop
                            }
                            isOurActivity = true;
                        }

                        //Make sure we have both attributes before processing
                        if ((activityUiOptions != null) && (activityPackage != null)) {
                            //Our activity, uiOptions specified, override with our value
                            uiOptions = activityUiOptions.intValue();
                        }
                    }
                    if (isOurActivity) {
                        //If we matched our activity but it had no logo don't
                        //do any more processing of the manifest
                        break;
                    }
                }
            }
            eventType = xml.nextToken();
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
    if (ActionBarSherlock.DEBUG) Log.i(TAG, "Returning " + Integer.toHexString(uiOptions));
    return uiOptions;
}