简书链接:多个客户定制的app名字一样另类识别技巧
文章字数:117,阅读全文大约需要1分钟
无意中看到别名技术实现桌面图标更换,于是我拿来区分客户。
但是测试的时候不太好区分,这个时候可以用别名。。
当然用channel定义不同字符串资源也是可以的
默认禁用,判断是测试版就启用。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
| <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是不存在的。
1 2 3 4 5 6 7 8 9 10
| 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 ); }
|