private Intent parseAlias(XmlPullParser xmlpullparser)
     throws XmlPullParserException, IOException
 {
     android.util.AttributeSet attributeset = Xml.asAttributeSet(xmlpullparser);
     Intent intent = null;
     int i;
     do
         i = xmlpullparser.next();
     while (i != 1 && i != 2);
     String s = xmlpullparser.getName();
     if (!"alias".equals(s))
         throw new RuntimeException((new StringBuilder()).append("Alias meta-data must start with <alias> tag; found").append(s).append(" at ").append(xmlpullparser.getPositionDescription()).toString());
     int j = xmlpullparser.getDepth();
     do
     {
         int k;
         do
         {
             k = xmlpullparser.next();
             if (k == 1 || k == 3 && xmlpullparser.getDepth() <= j)
                 return intent;
         } while (k == 3 || k == 4);
         if ("intent".equals(xmlpullparser.getName()))
         {
             Intent intent1 = Intent.parseIntent(getResources(), xmlpullparser, attributeset);
             if (intent == null)
                 intent = intent1;
         } else
         {
             XmlUtils.skipCurrentTag(xmlpullparser);
         }
     } while (true);
 }
  /**
   * Recursive method used to descend down the xml hierarchy and instantiate items, instantiate
   * their children, and then call onFinishInflate().
   */
  private void rInflate(XmlPullParser parser, Preference parent, final AttributeSet attrs)
      throws XmlPullParserException, IOException {
    final int depth = parser.getDepth();

    int type;
    while (((type = parser.next()) != XmlPullParser.END_TAG || parser.getDepth() > depth)
        && type != XmlPullParser.END_DOCUMENT) {

      if (type != XmlPullParser.START_TAG) {
        continue;
      }

      final String name = parser.getName();

      if (INTENT_TAG_NAME.equals(name)) {
        final Intent intent;

        try {
          intent = Intent.parseIntent(getContext().getResources(), parser, attrs);
        } catch (IOException e) {
          XmlPullParserException ex = new XmlPullParserException("Error parsing preference");
          ex.initCause(e);
          throw ex;
        }

        parent.setIntent(intent);
      } else if (EXTRA_TAG_NAME.equals(name)) {
        getContext().getResources().parseBundleExtra(EXTRA_TAG_NAME, attrs, parent.getExtras());
        try {
          skipCurrentTag(parser);
        } catch (IOException e) {
          XmlPullParserException ex = new XmlPullParserException("Error parsing preference");
          ex.initCause(e);
          throw ex;
        }
      } else {
        final Preference item = createItemFromTag(name, attrs);
        ((PreferenceGroup) parent).addItemFromInflater(item);
        rInflate(parser, item, attrs);
      }
    }
  }
  /**
   * Parse the given XML file as a header description, adding each parsed Header into the target
   * list.
   *
   * @param resid The XML resource to load and parse.
   * @param target The list in which the parsed headers should be placed.
   */
  public void loadHeadersFromResource(int resid, List<Header> target) {
    XmlResourceParser parser = null;
    try {
      parser = getResources().getXml(resid);
      AttributeSet attrs = Xml.asAttributeSet(parser);

      int type;
      while ((type = parser.next()) != XmlPullParser.END_DOCUMENT
          && type != XmlPullParser.START_TAG) {
        // Parse next until start tag is found
      }

      String nodeName = parser.getName();
      if (!"preference-headers".equals(nodeName)) {
        throw new RuntimeException(
            "XML document must start with <preference-headers> tag; found"
                + nodeName
                + " at "
                + parser.getPositionDescription());
      }

      Bundle curBundle = null;

      final int outerDepth = parser.getDepth();
      while ((type = parser.next()) != XmlPullParser.END_DOCUMENT
          && (type != XmlPullParser.END_TAG || parser.getDepth() > outerDepth)) {
        if (type == XmlPullParser.END_TAG || type == XmlPullParser.TEXT) {
          continue;
        }

        nodeName = parser.getName();
        if ("header".equals(nodeName)) {
          Header header = new Header();

          TypedArray sa = getResources().obtainAttributes(attrs, R.styleable.PreferenceHeader);
          header.id = sa.getResourceId(R.styleable.PreferenceHeader_id, (int) HEADER_ID_UNDEFINED);
          TypedValue tv = sa.peekValue(R.styleable.PreferenceHeader_title);
          if (tv != null && tv.type == TypedValue.TYPE_STRING) {
            if (tv.resourceId != 0) {
              header.titleRes = tv.resourceId;
            } else {
              header.title = tv.string;
            }
          }
          tv = sa.peekValue(R.styleable.PreferenceHeader_summary);
          if (tv != null && tv.type == TypedValue.TYPE_STRING) {
            if (tv.resourceId != 0) {
              header.summaryRes = tv.resourceId;
            } else {
              header.summary = tv.string;
            }
          }
          tv = sa.peekValue(R.styleable.PreferenceHeader_breadCrumbTitle);
          if (tv != null && tv.type == TypedValue.TYPE_STRING) {
            if (tv.resourceId != 0) {
              header.breadCrumbTitleRes = tv.resourceId;
            } else {
              header.breadCrumbTitle = tv.string;
            }
          }
          tv = sa.peekValue(R.styleable.PreferenceHeader_breadCrumbShortTitle);
          if (tv != null && tv.type == TypedValue.TYPE_STRING) {
            if (tv.resourceId != 0) {
              header.breadCrumbShortTitleRes = tv.resourceId;
            } else {
              header.breadCrumbShortTitle = tv.string;
            }
          }
          header.iconRes = sa.getResourceId(R.styleable.PreferenceHeader_icon, 0);
          header.fragment = sa.getString(R.styleable.PreferenceHeader_fragment);
          sa.recycle();

          if (curBundle == null) {
            curBundle = new Bundle();
          }

          final int innerDepth = parser.getDepth();
          while ((type = parser.next()) != XmlPullParser.END_DOCUMENT
              && (type != XmlPullParser.END_TAG || parser.getDepth() > innerDepth)) {
            if (type == XmlPullParser.END_TAG || type == XmlPullParser.TEXT) {
              continue;
            }

            String innerNodeName = parser.getName();
            if (innerNodeName.equals("extra")) {
              getResources().parseBundleExtra("extra", attrs, curBundle);
              XmlUtils.skipCurrentTag(parser);

            } else if (innerNodeName.equals("intent")) {
              header.intent = Intent.parseIntent(getResources(), parser, attrs);

            } else {
              XmlUtils.skipCurrentTag(parser);
            }
          }

          if (curBundle.size() > 0) {
            header.fragmentArguments = curBundle;
            curBundle = null;
          }

          target.add(header);
        } else {
          XmlUtils.skipCurrentTag(parser);
        }
      }

    } catch (XmlPullParserException e) {
      throw new RuntimeException("Error parsing headers", e);
    } catch (IOException e) {
      throw new RuntimeException("Error parsing headers", e);
    } finally {
      if (parser != null) parser.close();
    }
  }