1.首先在自己的apk中有一份黑名单的定义
<string-array name="black_list"> <item>com.google.android.apps.chrome.Main</item> </string-array>
2.在framework中定义方法获取里面的字串
private String[] getArrayBlackListApk(Context activity,String arrName){
String remotePackage = "com.xxx.xxx";//你定义了字串的应用名
Context remoteContext;
try {
remoteContext = activity.createPackageContext(remotePackage, Context.CONTEXT_IGNORE_SECURITY);
Resources remoteResources = remoteContext.getResources();
return remoteResources.getStringArray(remoteResources.getIdentifier(arrName, "array", remotePackage));
} catch (Exception e) {
e.printStackTrace();
return new String[0];
}
}