美文网首页
多个客户定制的app名字一样另类识别技巧

多个客户定制的app名字一样另类识别技巧

作者: 吉凶以情迁 | 来源:发表于2022-11-17 09:42 被阅读0次

无意中看到别名技术实现桌面图标更换,于是我拿来区分客户。
但是测试的时候不太好区分,这个时候可以用别名。。
当然用channel定义不同字符串资源也是可以的
默认禁用,判断是测试版就启用。

  <activity-alias
            android:icon="@drawable/company_logo"
            android:name="xxx.xxx.FullActivity"
            android:enabled="false"
            android:targetActivity="aaaa.SplashActivity"
            android:label="@string/app_name"
            android:exported="true">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />

            </intent-filter>
            <!--            用2个intent filter否则 无法在桌面显示-->
            <intent-filter>
                <action android:name="android.intent.action.VIEW" />

                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.BROWSABLE" />
                <data
                    android:host="splash"
                    android:scheme="${APP_SCHEME}" />

            </intent-filter>

        </activity-alias>

其中xxx.xxx.FullActivity是不存在的。

    public static void enableAlias(SuperContext superContext) {
        var newState = PackageManager.COMPONENT_ENABLED_STATE_ENABLED;
        ComponentName componentName = new ComponentName(superContext, "xxx.xxx.FullActivity");
        superContext.getPackageManager().setComponentEnabledSetting(
                componentName,
                newState,
                PackageManager.DONT_KILL_APP
        );
    }

相关文章

网友评论

      本文标题:多个客户定制的app名字一样另类识别技巧

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