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;
        }
     
     
  • 相关阅读:
    Android开发经验一判断当前屏幕是全屏还是非全屏
    Android得到控件在屏幕中的坐标
    MyBatis简单的增删改查以及简单的分页查询实现
    Coreseek:第二步建索引及測试
    极静之渊
    统计电影票房排名前10的电影并存入还有一个文件
    AAA
    FreeLink开源呼叫中心设计思想
    树后台数据存储(採用webmethod)
    [乐意黎原创] 百度统计这个坑爹货
  • 原文地址:https://www.cnblogs.com/wodehao0808/p/9071132.html
Copyright © 2011-2022 走看看