TextView autoLink不识别大写url问题

在部分手机发现此问题 大写的url不识别

用nexus+源生系统跟踪了一下源码  找到了原因 

Pattern的flags 在不同手机默认值不一样

so

反射修改之!

    static {
        final Pattern webUrl = Patterns.WEB_URL;
        try {
            Field flagsField = Pattern.class.getDeclaredField("flags");
            flagsField.setAccessible(true);
            flagsField.set(webUrl, Pattern.CASE_INSENSITIVE);
            Method compileMethod = Pattern.class.getDeclaredMethod("compile");
            compileMethod.setAccessible(true);
            compileMethod.invoke(webUrl);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

放在application onCretate就可以

原文地址:https://www.cnblogs.com/waterbear/p/4627596.html