代码:
public static boolean isConfigInstalled(PackageManager pm, String pkg, String conf) throws PackageManager.NameNotFoundException
{
// get application info for installed app
ApplicationInfo ai=pm.getApplicationInfo(pkg, 0);
// get installed split's Names
String[] sn=ai.splitNames;
// check whether if it's really split or not
if (sn != null && sn.length > 0)
{
// search installed splits
for(String n:sn){
// check whether is the one required
if(n.equals("config." + conf)){
// yes, it's installed!
return true;
}
}
}
// couldn't find!
return false;
}
如何使用:
只需传递您通过context.getPackageManager()获得的包管理器以及应用程序的包名称和语言代码
例子:
PackageManager pm=getPackageManager();
String pkg="com.snapchat.android";
String languageCode="ur";
if(isConfigInstalled(pm, pkg, languageCode)){
System.out.println("Snapchat has Urdu Installed!");
}else{
System.out.println("Snapchat doesn't has Urdu Installed!");
}
输出:
Snapchat has Urdu Installed!