zoukankan      html  css  js  c++  java
  • (转)META-INF/channel_获取方法

    private static String channel = null;

     
        public static String getChannel(Context context) {
            if (channel != null) {
                return channel;
            }
     
            final String start_flag = "META-INF/channel_";
            ApplicationInfo appinfo = context.getApplicationInfo();
            String sourceDir = appinfo.sourceDir;
            ZipFile zipfile = null;
            try {
                zipfile = new ZipFile(sourceDir);
                Enumeration<?> entries = zipfile.entries();
                while (entries.hasMoreElements()) {
                    ZipEntry entry = ((ZipEntry) entries.nextElement());
                    String entryName = entry.getName();
                    if (entryName.contains(start_flag)) {
                        channel = entryName.replace(start_flag, "");
                        break;
                    }
                }
            catch (IOException e) {
                e.printStackTrace();
            finally {
                if (zipfile != null) {
                    try {
                        zipfile.close();
                    catch (IOException e) {
                        e.printStackTrace();
                    }
                }
            }
     
            if (channel == null || channel.length() <= 0) {
                channel = "10000";//读不到渠道号就默认官方渠道
            }
            return channel;
        }
     
     
  • 相关阅读:
    ADC推荐:测量Flash的视频消费行为 (转载)
    9.7Go之函数之递归函数
    9.8线性表之单链表
    9.7线性表之顺序表
    9.7顺序表之增、删、改、查
    9.8Go之函数之计算执行时间
    9.8Go之函数之宕机(panic)
    9.9Go语言内存缓存
    9.7Go之函数之处理RuntimeError
    9.7Go之函数之defer(延迟执行语句)
  • 原文地址:https://www.cnblogs.com/wodehao0808/p/9071132.html
Copyright © 2011-2022 走看看