美文网首页发现代码之美
Android系统中位运算符的妙用

Android系统中位运算符的妙用

作者: 锄禾豆 | 来源:发表于2021-05-28 18:52 被阅读0次

    重点关注

    PackageManager
    
        public static final int GET_ACTIVITIES              = 0x00000001;
    
        public static final int GET_RECEIVERS               = 0x00000002;
    
    
        public static final int GET_SERVICES                = 0x00000004;
    
    
        public static final int GET_PROVIDERS               = 0x00000008;
    
    
        public static final int GET_INSTRUMENTATION         = 0x00000010;
    
    
        public static final int GET_INTENT_FILTERS          = 0x00000020;
    
    
        public static final int GET_SIGNATURES          = 0x00000040;
    
    
        public static final int GET_RESOLVED_FILTER         = 0x00000040;
    
    
        public static final int GET_META_DATA               = 0x00000080;
    
    
        public static final int GET_GIDS                    = 0x00000100;
    
    
        public static final int MATCH_DISABLED_COMPONENTS = 0x00000200;
    
    
        public static final int GET_SHARED_LIBRARY_FILES    = 0x00000400;
    
    
        public static final int GET_URI_PERMISSION_PATTERNS  = 0x00000800;
    
    
        public static final int GET_PERMISSIONS               = 0x00001000;
    
    
        public static final int MATCH_UNINSTALLED_PACKAGES = 0x00002000;
    
    
        public static final int GET_CONFIGURATIONS = 0x00004000;
    
    
        public static final int MATCH_DISABLED_UNTIL_USED_COMPONENTS = 0x00008000;
    
    
        public static final int MATCH_DEFAULT_ONLY  = 0x00010000;
    
    
        public static final int MATCH_ALL = 0x00020000;
    
    
        public static final int MATCH_DIRECT_BOOT_UNAWARE = 0x00040000;
    
    
        public static final int MATCH_DIRECT_BOOT_AWARE = 0x00080000;
    
    
        public static final int MATCH_SYSTEM_ONLY = 0x00100000;
    
    
        public static final int MATCH_FACTORY_ONLY = 0x00200000;
    

    找规律

    十六进制
    1        2        4        8 
    10       20       40       80
    100      200      400      800
    1000     2000     4000     8000
    10000    20000    40000    80000
    
    对应的二进制
    2^0^     2^1^     2^2^     2^3^
    2^4^     2^5^     2^6^     2^7^
    2^8^     2^9^     2^10^    2^11^
    2^12^    2^13^    2^14^    2^15^
    

    位运算

    1)位运预算针对的是二进制
    2)从十六进制对应到二进制,再理解使用"|"(与)位运算符,则一定会得出不一样值。这里不管怎么排列组合。
    这种活用、易被采纳使用的做法,就是高级货。注意:我们在使用|或&目的为了判断,所以,不要太关注此值。
    

    相关文章

      网友评论

        本文标题:Android系统中位运算符的妙用

        本文链接:https://www.haomeiwen.com/subject/ixtesltx.html