[英]how to check if Google Assistant is available in a device by code?
Is Google Assistant available in all Android devices? Google 助理是否适用于所有 Android 设备?
Is there any way to check it programmatically?有没有办法以编程方式检查它?
I need to know if the current device has it available in order to offer some options to the user.我需要知道当前设备是否可用,以便为用户提供一些选项。 As far as I know, at least new Huawei Android devices will not come with any Google features, right?
据我所知,至少新的华为安卓设备不会配备任何谷歌功能,对吧? Neither the Assistant.
助理也不行。 So is there a way to check that?
那么有没有办法检查呢? Maybe a function like this:
也许是这样的功能:
IsGoogleAssistantAvailable()
Use this method to check if app is installed-使用此方法检查是否安装了应用程序-
private boolean appInstalledOrNot(String uri) {
PackageManager pm = getPackageManager();
try {
pm.getPackageInfo(uri, PackageManager.GET_ACTIVITIES);
return true;
} catch (PackageManager.NameNotFoundException e) {
}
return false;
}
Check like this像这样检查
For Google Assistant-对于 Google 助理-
boolean isAppInstalled = appInstalledOrNot("com.google.android.apps.googleassistant");
For Google Assistant Go use this package name - com.google.android.apps.assistant
对于 Google Assistant Go 使用这个包名 -
com.google.android.apps.assistant
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.