永发信息网

android studio 多聚道打包 怎么获取当前聚道名称

答案:2  悬赏:10  手机版
解决时间 2021-01-25 11:51
  • 提问者网友:ミ烙印ゝ
  • 2021-01-24 18:26
android studio 多聚道打包 怎么获取当前聚道名称
最佳答案
  • 五星知识达人网友:woshuo
  • 2021-01-24 19:26
public static String getChannel(Context context) {
        ApplicationInfo appinfo = context.getApplicationInfo();
        String sourceDir = appinfo.sourceDir;
        String ret = "";
        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.startsWith("mtchannel")) {
                    ret = entryName;
                    break;
                }
            }
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            if (zipfile != null) {
                try {
                    zipfile.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }

        String[] split = ret.split("_");
        if (split != null && split.length >= 2) {
            return ret.substring(split[0].length() + 1);

        } else {
            return "";
        }
    }
全部回答
  • 1楼网友:春色三分
  • 2021-01-24 20:50
搜一下:android studio 多聚道打包 怎么获取当前聚道名称
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯