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

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

源代码1 项目: LaunchEnr   文件: IconThemer.java
private Drawable getRoundIcon(Context context,String packageName, int iconDpi) {

        mPackageManager = context.getPackageManager();

        try {
            Resources resourcesForApplication = mPackageManager.getResourcesForApplication(packageName);
            AssetManager assets = resourcesForApplication.getAssets();
            XmlResourceParser parseXml = assets.openXmlResourceParser("AndroidManifest.xml");
            int eventType;
            while ((eventType = parseXml.nextToken()) != XmlPullParser.END_DOCUMENT)
                if (eventType == XmlPullParser.START_TAG && parseXml.getName().equals("application"))
                    for (int i = 0; i < parseXml.getAttributeCount(); i++)
                        if (parseXml.getAttributeName(i).equals("roundIcon"))
                            return resourcesForApplication.getDrawableForDensity(Integer.parseInt(parseXml.getAttributeValue(i).substring(1)), iconDpi, context.getTheme());
            parseXml.close();
        }
        catch (Exception ex) {
            ex.printStackTrace();
        }
        return null;
    }
 
源代码2 项目: AppTroy   文件: ResourceDump.java
private void getAttributes(StringBuilder sb, XmlResourceParser parser) throws XmlPullParserException {
    int count = parser.getAttributeCount();
    for (int i = 0; i < count; i++) {
        sb.append(" ");
        String namespace = parser.getAttributeNamespace(i);
        if (namespace != null) {
            int index = namespace.lastIndexOf("/");
            if (index > 0) {
                namespace = namespace.substring(index + 1);
            }
            sb.append(namespace);
            sb.append(":");
        }
        sb.append(parser.getAttributeName(i));
        sb.append("=");
        sb.append(parser.getAttributeValue(i));
    }
}
 
源代码3 项目: cwac-netsecurity   文件: TrustManagerBuilder.java
private void validateConfig(Context ctxt, int resourceId,
                            boolean isUserAllowed) {
  XmlResourceParser xpp=ctxt.getResources().getXml(resourceId);
  RuntimeException result=null;

  try {
    while (xpp.getEventType()!=XmlPullParser.END_DOCUMENT) {
      if (xpp.getEventType()==XmlPullParser.START_TAG) {
        if ("certificates".equals(xpp.getName())) {
          for (int i=0; i<xpp.getAttributeCount(); i++) {
            String name=xpp.getAttributeName(i);

            if ("src".equals(name)) {
              String src=xpp.getAttributeValue(i);

              if ("user".equals(src)) {
                if (isUserAllowed) {
                  Log.w("CWAC-NetSecurity", "requested <certificates src=\"user\">, treating as <certificates src=\"system\">");
                }
                else {
                  result=new RuntimeException(
                    "requested <certificates src=\"user\">, not supported");
                }
              }
            }
          }
        }
      }

      xpp.next();
    }
  }
  catch (Exception e) {
    throw new RuntimeException("Could not parse config XML", e);
  }

  if (result!=null) {
    throw result;
  }
}
 
源代码4 项目: fdroidclient   文件: App.java
/**
 * {@link PackageManager} doesn't give us {@code minSdkVersion}, {@code targetSdkVersion},
 * and {@code maxSdkVersion}, so we have to parse it straight from {@code <uses-sdk>} in
 * {@code AndroidManifest.xml}.  If {@code targetSdkVersion} is not set, then it is
 * equal to {@code minSdkVersion}
 *
 * @see <a href="https://developer.android.com/guide/topics/manifest/uses-sdk-element.html">&lt;uses-sdk&gt;</a>
 */
private static int[] getMinTargetMaxSdkVersions(Context context, String packageName) {
    int minSdkVersion = Apk.SDK_VERSION_MIN_VALUE;
    int targetSdkVersion = Apk.SDK_VERSION_MIN_VALUE;
    int maxSdkVersion = Apk.SDK_VERSION_MAX_VALUE;
    try {
        AssetManager am = context.createPackageContext(packageName, 0).getAssets();
        XmlResourceParser xml = am.openXmlResourceParser("AndroidManifest.xml");
        int eventType = xml.getEventType();
        while (eventType != XmlPullParser.END_DOCUMENT) {
            if (eventType == XmlPullParser.START_TAG && "uses-sdk".equals(xml.getName())) {
                for (int j = 0; j < xml.getAttributeCount(); j++) {
                    if (xml.getAttributeName(j).equals("minSdkVersion")) {
                        minSdkVersion = Integer.parseInt(xml.getAttributeValue(j));
                    } else if (xml.getAttributeName(j).equals("targetSdkVersion")) {
                        targetSdkVersion = Integer.parseInt(xml.getAttributeValue(j));
                    } else if (xml.getAttributeName(j).equals("maxSdkVersion")) {
                        maxSdkVersion = Integer.parseInt(xml.getAttributeValue(j));
                    }
                }
                break;
            }
            eventType = xml.nextToken();
        }
    } catch (PackageManager.NameNotFoundException
            | IOException
            | XmlPullParserException
            | NumberFormatException e) {
        Log.e(TAG, "Could not get min/max sdk version", e);
    }
    if (targetSdkVersion < minSdkVersion) {
        targetSdkVersion = minSdkVersion;
    }
    return new int[]{minSdkVersion, targetSdkVersion, maxSdkVersion};
}
 
源代码5 项目: android_9.0.0_r45   文件: XmlConfigSource.java
private List<Pair<NetworkSecurityConfig.Builder, Set<Domain>>> parseConfigEntry(
        XmlResourceParser parser, Set<String> seenDomains,
        NetworkSecurityConfig.Builder parentBuilder, int configType)
        throws IOException, XmlPullParserException, ParserException {
    List<Pair<NetworkSecurityConfig.Builder, Set<Domain>>> builders = new ArrayList<>();
    NetworkSecurityConfig.Builder builder = new NetworkSecurityConfig.Builder();
    builder.setParent(parentBuilder);
    Set<Domain> domains = new ArraySet<>();
    boolean seenPinSet = false;
    boolean seenTrustAnchors = false;
    boolean defaultOverridePins = configType == CONFIG_DEBUG;
    String configName = parser.getName();
    int outerDepth = parser.getDepth();
    // Add this builder now so that this builder occurs before any of its children. This
    // makes the final build pass easier.
    builders.add(new Pair<>(builder, domains));
    // Parse config attributes. Only set values that are present, config inheritence will
    // handle the rest.
    for (int i = 0; i < parser.getAttributeCount(); i++) {
        String name = parser.getAttributeName(i);
        if ("hstsEnforced".equals(name)) {
            builder.setHstsEnforced(
                    parser.getAttributeBooleanValue(i,
                            NetworkSecurityConfig.DEFAULT_HSTS_ENFORCED));
        } else if ("cleartextTrafficPermitted".equals(name)) {
            builder.setCleartextTrafficPermitted(
                    parser.getAttributeBooleanValue(i,
                            NetworkSecurityConfig.DEFAULT_CLEARTEXT_TRAFFIC_PERMITTED));
        }
    }
    // Parse the config elements.
    while (XmlUtils.nextElementWithin(parser, outerDepth)) {
        String tagName = parser.getName();
        if ("domain".equals(tagName)) {
            if (configType != CONFIG_DOMAIN) {
                throw new ParserException(parser,
                        "domain element not allowed in " + getConfigString(configType));
            }
            Domain domain = parseDomain(parser, seenDomains);
            domains.add(domain);
        } else if ("trust-anchors".equals(tagName)) {
            if (seenTrustAnchors) {
                throw new ParserException(parser,
                        "Multiple trust-anchor elements not allowed");
            }
            builder.addCertificatesEntryRefs(
                    parseTrustAnchors(parser, defaultOverridePins));
            seenTrustAnchors = true;
        } else if ("pin-set".equals(tagName)) {
            if (configType != CONFIG_DOMAIN) {
                throw new ParserException(parser,
                        "pin-set element not allowed in " + getConfigString(configType));
            }
            if (seenPinSet) {
                throw new ParserException(parser, "Multiple pin-set elements not allowed");
            }
            builder.setPinSet(parsePinSet(parser));
            seenPinSet = true;
        } else if ("domain-config".equals(tagName)) {
            if (configType != CONFIG_DOMAIN) {
                throw new ParserException(parser,
                        "Nested domain-config not allowed in " + getConfigString(configType));
            }
            builders.addAll(parseConfigEntry(parser, seenDomains, builder, configType));
        } else {
            XmlUtils.skipCurrentTag(parser);
        }
    }
    if (configType == CONFIG_DOMAIN && domains.isEmpty()) {
        throw new ParserException(parser, "No domain elements in domain-config");
    }
    return builders;
}
 
源代码6 项目: 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;
}
 
源代码7 项目: CSipSimple   文件: Utility4.java
/**
 * Attempt to programmatically load the logo from the manifest file of an
 * activity by using an XML pull parser. This should allow us to read the
 * logo attribute regardless of the platform it is being run on.
 *
 * @param activity Activity instance.
 * @return Logo resource ID.
 */
private static int loadLogoFromManifest(Activity activity) {
    int logo = 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 ("logo".equals(xml.getAttributeName(i))) {
                            logo = xml.getAttributeResourceValue(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 activityLogo = 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 ("logo".equals(attrName)) {
                            activityLogo = xml.getAttributeResourceValue(i, 0);
                        } else if ("name".equals(attrName)) {
                            activityPackage = ActionBarSherlockCompat.cleanActivityName(packageName, xml.getAttributeValue(i));
                            if (!thisPackage.equals(activityPackage)) {
                                break; //on to the next
                            }
                            isOurActivity = true;
                        }

                        //Make sure we have both attributes before processing
                        if ((activityLogo != null) && (activityPackage != null)) {
                            //Our activity, logo specified, override with our value
                            logo = activityLogo.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(logo));
    return logo;
}
 
源代码8 项目: CSipSimple   文件: ResourcesCompat.java
/**
 * Attempt to programmatically load the logo from the manifest file of an
 * activity by using an XML pull parser. This should allow us to read the
 * logo attribute regardless of the platform it is being run on.
 *
 * @param activity Activity instance.
 * @return Logo resource ID.
 */
public static int loadLogoFromManifest(Activity activity) {
    int logo = 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 ("logo".equals(xml.getAttributeName(i))) {
                            logo = xml.getAttributeResourceValue(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 activityLogo = 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 ("logo".equals(attrName)) {
                            activityLogo = xml.getAttributeResourceValue(i, 0);
                        } else if ("name".equals(attrName)) {
                            activityPackage = ActionBarSherlockCompat.cleanActivityName(packageName, xml.getAttributeValue(i));
                            if (!thisPackage.equals(activityPackage)) {
                                break; //on to the next
                            }
                            isOurActivity = true;
                        }

                        //Make sure we have both attributes before processing
                        if ((activityLogo != null) && (activityPackage != null)) {
                            //Our activity, logo specified, override with our value
                            logo = activityLogo.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(logo));
    return logo;
}
 
源代码9 项目: cwac-netsecurity   文件: XmlConfigSource.java
private List<Pair<NetworkSecurityConfig.Builder, Set<Domain>>> parseConfigEntry(
        XmlResourceParser parser, Set<String> seenDomains,
        NetworkSecurityConfig.Builder parentBuilder, int configType)
        throws IOException, XmlPullParserException, ParserException {
    List<Pair<NetworkSecurityConfig.Builder, Set<Domain>>> builders = new ArrayList<>();
    NetworkSecurityConfig.Builder builder = new NetworkSecurityConfig.Builder();
    builder.setParent(parentBuilder);
    Set<Domain> domains = new HashSet<>();
    boolean seenPinSet = false;
    boolean seenTrustAnchors = false;
    boolean defaultOverridePins = configType == CONFIG_DEBUG;
    String configName = parser.getName();
    int outerDepth = parser.getDepth();
    // Add this builder now so that this builder occurs before any of its children. This
    // makes the final build pass easier.
    builders.add(new Pair<>(builder, domains));
    // Parse config attributes. Only set values that are present, config inheritence will
    // handle the rest.
    for (int i = 0; i < parser.getAttributeCount(); i++) {
        String name = parser.getAttributeName(i);
        if ("hstsEnforced".equals(name)) {
            builder.setHstsEnforced(
                    parser.getAttributeBooleanValue(i,
                            NetworkSecurityConfig.DEFAULT_HSTS_ENFORCED));
        } else if ("cleartextTrafficPermitted".equals(name)) {
            builder.setCleartextTrafficPermitted(
                    parser.getAttributeBooleanValue(i,
                            NetworkSecurityConfig.DEFAULT_CLEARTEXT_TRAFFIC_PERMITTED));
        }
    }
    // Parse the config elements.
    while (XmlUtils.nextElementWithin(parser, outerDepth)) {
        String tagName = parser.getName();
        if ("domain".equals(tagName)) {
            if (configType != CONFIG_DOMAIN) {
                throw new ParserException(parser,
                        "domain element not allowed in " + getConfigString(configType));
            }
            Domain domain = parseDomain(parser, seenDomains);
            domains.add(domain);
        } else if ("trust-anchors".equals(tagName)) {
            if (seenTrustAnchors) {
                throw new ParserException(parser,
                        "Multiple trust-anchor elements not allowed");
            }
            builder.addCertificatesEntryRefs(
                    parseTrustAnchors(parser, defaultOverridePins));
            seenTrustAnchors = true;
        } else if ("pin-set".equals(tagName)) {
            if (configType != CONFIG_DOMAIN) {
                throw new ParserException(parser,
                        "pin-set element not allowed in " + getConfigString(configType));
            }
            if (seenPinSet) {
                throw new ParserException(parser, "Multiple pin-set elements not allowed");
            }
            builder.setPinSet(parsePinSet(parser));
            seenPinSet = true;
        } else if ("domain-config".equals(tagName)) {
            if (configType != CONFIG_DOMAIN) {
                throw new ParserException(parser,
                        "Nested domain-config not allowed in " + getConfigString(configType));
            }
            builders.addAll(parseConfigEntry(parser, seenDomains, builder, configType));
        } else {
            XmlUtils.skipCurrentTag(parser);
        }
    }
    if (configType == CONFIG_DOMAIN && domains.isEmpty()) {
        throw new ParserException(parser, "No domain elements in domain-config");
    }
    return builders;
}
 
源代码10 项目: BottomBar   文件: TabParser.java
@NonNull
private BottomBarTab parseNewTab(@NonNull XmlResourceParser parser, @IntRange(from = 0) int containerPosition) {
    BottomBarTab workingTab = tabWithDefaults();
    workingTab.setIndexInContainer(containerPosition);

    final int numberOfAttributes = parser.getAttributeCount();
    for (int i = 0; i < numberOfAttributes; i++) {
        @TabAttribute
        String attrName = parser.getAttributeName(i);
        switch (attrName) {
            case ID:
                workingTab.setId(parser.getIdAttributeResourceValue(i));
                break;
            case ICON:
                workingTab.setIconResId(parser.getAttributeResourceValue(i, RESOURCE_NOT_FOUND));
                break;
            case TITLE:
                workingTab.setTitle(getTitleValue(parser, i));
                break;
            case INACTIVE_COLOR:
                int inactiveColor = getColorValue(parser, i);
                if (inactiveColor == COLOR_NOT_SET) continue;
                workingTab.setInActiveColor(inactiveColor);
                break;
            case ACTIVE_COLOR:
                int activeColor = getColorValue(parser, i);
                if (activeColor == COLOR_NOT_SET) continue;
                workingTab.setActiveColor(activeColor);
                break;
            case BAR_COLOR_WHEN_SELECTED:
                int barColorWhenSelected = getColorValue(parser, i);
                if (barColorWhenSelected == COLOR_NOT_SET) continue;
                workingTab.setBarColorWhenSelected(barColorWhenSelected);
                break;
            case BADGE_BACKGROUND_COLOR:
                int badgeBackgroundColor = getColorValue(parser, i);
                if (badgeBackgroundColor == COLOR_NOT_SET) continue;
                workingTab.setBadgeBackgroundColor(badgeBackgroundColor);
                break;
            case BADGE_HIDES_WHEN_ACTIVE:
                boolean badgeHidesWhenActive = parser.getAttributeBooleanValue(i, true);
                workingTab.setBadgeHidesWhenActive(badgeHidesWhenActive);
                break;
            case IS_TITLELESS:
                boolean isTitleless = parser.getAttributeBooleanValue(i, false);
                workingTab.setIsTitleless(isTitleless);
                break;
        }
    }

    return workingTab;
}
 
/**
 * Attempt to programmatically load the logo from the manifest file of an
 * activity by using an XML pull parser. This should allow us to read the
 * logo attribute regardless of the platform it is being run on.
 *
 * @param activity Activity instance.
 * @return Logo resource ID.
 */
public static int loadLogoFromManifest(Activity activity) {
    int logo = 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 ("logo".equals(xml.getAttributeName(i))) {
                            logo = xml.getAttributeResourceValue(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 activityLogo = 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 ("logo".equals(attrName)) {
                            activityLogo = xml.getAttributeResourceValue(i, 0);
                        } else if ("name".equals(attrName)) {
                            activityPackage = ActionBarSherlockCompat.cleanActivityName(packageName, xml.getAttributeValue(i));
                            if (!thisPackage.equals(activityPackage)) {
                                break; //on to the next
                            }
                            isOurActivity = true;
                        }

                        //Make sure we have both attributes before processing
                        if ((activityLogo != null) && (activityPackage != null)) {
                            //Our activity, logo specified, override with our value
                            logo = activityLogo.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(logo));
    return logo;
}
 
源代码12 项目: 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);
}
 
源代码13 项目: 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);
}
 
源代码14 项目: 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;
}
 
源代码15 项目: android-apps   文件: ActionBarView.java
/**
 * Attempt to programmatically load the logo from the manifest file of an
 * activity by using an XML pull parser. This should allow us to read the
 * logo attribute regardless of the platform it is being run on.
 *
 * @param activity Activity instance.
 * @return Logo resource ID.
 */
private static int loadLogoFromManifest(Activity activity) {
    int logo = 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 ("logo".equals(xml.getAttributeName(i))) {
                            logo = xml.getAttributeResourceValue(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 activityLogo = 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 ("logo".equals(attrName)) {
                            activityLogo = xml.getAttributeResourceValue(i, 0);
                        } else if ("name".equals(attrName)) {
                            activityPackage = ActionBarSherlockCompat.cleanActivityName(packageName, xml.getAttributeValue(i));
                            if (!thisPackage.equals(activityPackage)) {
                                break; //on to the next
                            }
                            isOurActivity = true;
                        }

                        //Make sure we have both attributes before processing
                        if ((activityLogo != null) && (activityPackage != null)) {
                            //Our activity, logo specified, override with our value
                            logo = activityLogo.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(logo));
    return logo;
}
 
源代码16 项目: 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;
}
 
源代码17 项目: zen4android   文件: ResourcesCompat.java
/**
 * Attempt to programmatically load the logo from the manifest file of an
 * activity by using an XML pull parser. This should allow us to read the
 * logo attribute regardless of the platform it is being run on.
 *
 * @param activity Activity instance.
 * @return Logo resource ID.
 */
public static int loadLogoFromManifest(Activity activity) {
    int logo = 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 ("logo".equals(xml.getAttributeName(i))) {
                            logo = xml.getAttributeResourceValue(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 activityLogo = 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 ("logo".equals(attrName)) {
                            activityLogo = xml.getAttributeResourceValue(i, 0);
                        } else if ("name".equals(attrName)) {
                            activityPackage = ActionBarSherlockCompat.cleanActivityName(packageName, xml.getAttributeValue(i));
                            if (!thisPackage.equals(activityPackage)) {
                                break; //on to the next
                            }
                            isOurActivity = true;
                        }

                        //Make sure we have both attributes before processing
                        if ((activityLogo != null) && (activityPackage != null)) {
                            //Our activity, logo specified, override with our value
                            logo = activityLogo.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(logo));
    return logo;
}
 
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;
}
 
源代码19 项目: zhangshangwuda   文件: ResourcesCompat.java
/**
 * Attempt to programmatically load the logo from the manifest file of an
 * activity by using an XML pull parser. This should allow us to read the
 * logo attribute regardless of the platform it is being run on.
 *
 * @param activity Activity instance.
 * @return Logo resource ID.
 */
public static int loadLogoFromManifest(Activity activity) {
    int logo = 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 ("logo".equals(xml.getAttributeName(i))) {
                            logo = xml.getAttributeResourceValue(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 activityLogo = 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 ("logo".equals(attrName)) {
                            activityLogo = xml.getAttributeResourceValue(i, 0);
                        } else if ("name".equals(attrName)) {
                            activityPackage = ActionBarSherlockCompat.cleanActivityName(packageName, xml.getAttributeValue(i));
                            if (!thisPackage.equals(activityPackage)) {
                                break; //on to the next
                            }
                            isOurActivity = true;
                        }

                        //Make sure we have both attributes before processing
                        if ((activityLogo != null) && (activityPackage != null)) {
                            //Our activity, logo specified, override with our value
                            logo = activityLogo.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(logo));
    return logo;
}
 
源代码20 项目: cwac-provider   文件: StreamProvider.java
private CompositeStreamStrategy parseStreamStrategy(final CompositeStreamStrategy result,
                                                    Context context,
                                                    String authority)
  throws IOException, XmlPullParserException {
  final ProviderInfo info=
    context.getPackageManager()
      .resolveContentProvider(authority,
        PackageManager.GET_META_DATA);

  useLegacyCursorWrapper=info.metaData.getBoolean(META_DATA_USE_LEGACY_CURSOR_WRAPPER, true);
  useUriForDataColumn=info.metaData.getBoolean(META_DATA_USE_URI_FOR_DATA_COLUMN, false);

  final XmlResourceParser in=
    info.loadXmlMetaData(context.getPackageManager(),
      META_DATA_FILE_PROVIDER_PATHS);

  if (in == null) {
    throw new IllegalArgumentException("Missing "
      + META_DATA_FILE_PROVIDER_PATHS + " meta-data");
  }

  int type;

  while ((type=in.next()) != org.xmlpull.v1.XmlPullParser.END_DOCUMENT) {
    if (type == org.xmlpull.v1.XmlPullParser.START_TAG) {
      final String tag=in.getName();

      if (!"paths".equals(tag)) {
        final String name=in.getAttributeValue(null, ATTR_NAME);

        if (TextUtils.isEmpty(name)) {
          throw new IllegalArgumentException("Name must not be empty");
        }

        String path=in.getAttributeValue(null, ATTR_PATH);
        boolean readOnly=allReadOnly ||
          Boolean.parseBoolean(in.getAttributeValue(null, ATTR_READ_ONLY));
        HashMap<String, String> attrs=new HashMap<String, String>();

        for (int i=0;i<in.getAttributeCount();i++) {
          attrs.put(in.getAttributeName(i), in.getAttributeValue(i));
        }

        StreamStrategy strategy=
          buildStrategy(context, tag, name, path, readOnly, attrs);

        if (strategy != null) {
          result.add(name, strategy);
        }
        else {
          throw new IllegalArgumentException("Could not build strategy for "
            + tag);
        }
      }
    }
  }

  return(result);
}