예제 #1
0
        private void ParseRootElement(AXmlResourceParser parser)
        {
            for (int i = parser.getAttributeCount() - 1; i >= 0; --i)
            {
                switch (parser.getAttributeName(i))
                {
                case "versionName":
                    this.VersionName = parser.getAttributeValue(i);
                    break;

                case "versionCode":
                    this.VersionCode = parser.getAttributeValueData(i).ToString();
                    break;

                case "package":
                    this.PackageName = parser.getAttributeValue(i);
                    break;
                }
            }
        }
예제 #2
0
        public AndriodManifest(byte[] data)
        {
            if (data == null || data.Length == 0)
            {
                return;
            }
            java.io.InputStream input = new java.io.ByteArrayInputStream(data);
            try {
                AXmlResourceParser parser = new AXmlResourceParser();
                parser.open(input);
                while (true)
                {
                    int type = parser.next();
                    if (type == XmlPullParser.__Fields.END_DOCUMENT)
                    {
                        break;
                    }
                    if (type == XmlPullParser.__Fields.START_TAG)
                    {
                        switch (parser.getDepth())
                        {
                        case 1:
                            if ("manifest" == parser.getName())
                            {
                                ParseRootElement(parser);
                            }
                            break;

                        case 3:
                            if ("meta-data" == parser.getName())
                            {
                                ParseMetaDataElement(parser);
                            }
                            break;
                        }
                    }
                }
            } finally {
                input.close();
            }
        }
예제 #3
0
        private void ParseMetaDataElement(AXmlResourceParser parser)
        {
            String name  = null;
            String value = null;

            for (int i = parser.getAttributeCount() - 1; i >= 0; --i)
            {
                string s = parser.getAttributeName(i);
                switch (s)
                {
                case "name":
                    name = parser.getAttributeValue(i);
                    break;

                case "value":
                    value = parser.getAttributeValue(i);
                    break;
                }
            }
            if (String.IsNullOrEmpty(name) || String.IsNullOrEmpty(value))
            {
                return;
            }
            switch (name)
            {
            case "UMENG_APPKEY":
                this.UmengKey = value;
                break;

            case "UMENG_CHANNEL":
                this.UmengChannel = value;
                break;

            case "JPUSH_APPKEY":
                this.JPushKey = value;
                break;
            }
        }