Skip to content

Yemesoft/AndroidTool

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 

Repository files navigation

由于360多渠道打包工具开始收费了,所以做了个小工具免费给大家使用。 比360打包更快,零代码侵入。

欢迎加入QQ交流群:601971480

渠道配置文件和360渠道配置文件一样。

渠道名获取方法:


public class ChannelUtil {
    private static final String CHANNEL_FILE_PREFIX = "_app_channel_";

    public static String getChannelName(Context context) {
        String channelName = null;
        try {
            String zipPath = context.getPackageResourcePath();
            ZipFile zipFile = new ZipFile(zipPath);
            Enumeration<? extends ZipEntry> entries = zipFile.entries();
            while (entries.hasMoreElements()) {
                ZipEntry entry = entries.nextElement();
                if (entry.getName().startsWith(CHANNEL_FILE_PREFIX)) {
                    channelName = entry.getName().substring(CHANNEL_FILE_PREFIX.length());
                    break;
                }
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
        if (null == channelName) {
            try {
                //兼容友盟
                ApplicationInfo applicationInfo = context.getPackageManager().getApplicationInfo(context.getPackageName(), PackageManager.GET_META_DATA);
                channelName = applicationInfo.metaData.getString("UMENG_CHANNEL");
            } catch (PackageManager.NameNotFoundException e) {
                e.printStackTrace();
            }
        }
        System.err.println("channelName=" + channelName);
        if (null == channelName) {
            channelName = "normal";
        }
        return channelName;
    }

}



About

安卓,快速,多渠道打包,代码零侵入

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published