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;
        }
     
     
  • 相关阅读:
    git pull遇到错误:error: Your local changes to the following files would be overwritten by merge:
    angular 过滤器(日期转换,时间转换,数据转换等)
    js 毫秒转天时分秒
    使用Vue-Router 2实现路由功能
    vue-cli中安装方法
    Vue 2.5 发布了:15篇前端热文回看
    es6 语法 (模块化)
    es6 语法 (Decorator)
    es6 语法 (Generator)
    js 判断当前是什么浏览器
  • 原文地址:https://www.cnblogs.com/wodehao0808/p/9071132.html
Copyright © 2011-2022 走看看