我想问一下,...在Android设备上检测Google Voice Search(app id:com.google.android.voicesearch)安装的最有效方法是什么? 是否有任何方法可以随后安装它而无需将用户带到Play Market并返回应用程序?
答案 0 :(得分:2)
您可以使用以下方法
private boolean voiceSearchExists() {
final Intent mainIntent = new Intent(Intent.ACTION_MAIN, null);
mainIntent.addCategory(Intent.CATEGORY_LAUNCHER);
List<PackageInfo> packs = getPackageManager().getInstalledPackages(0);
final List<ResolveInfo> pkgAppsList = getPackageManager().queryIntentActivities( mainIntent, 0);
boolean packageExists = false;
boolean activityExists = false;
for(PackageInfo r:packs){
String pkg = r.applicationInfo.packageName;
if(pkg != null && pkg.equals("com.google.android.googlequicksearchbox")){
packageExists = true;
break;
}
}
if(packageExists == false)
return false;
for(ResolveInfo r:pkgAppsList){
ActivityInfo info = r.activityInfo;
if(info!=null && info.name!=null && info.name.equals("com.google.android.googlequicksearchbox.VoiceSearchActivity")){
activityExists = true;
break;
}
}
return activityExists;
}