简体   繁体   English

如何通过代码检查设备中是否可以使用 Google Assistant?

[英]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.

相关问题 如何检查Android设备上是否有Google身份验证器? - how to check if Google authenticator is available on a Android device? 自定义Google智能助理突然在设备上不可用,但在输入提示时有效 - Custom Google Assistant suddenly not available on device, but works when the prompt is typed in 如何将Google Assistant SDK(库组件)与Android设备集成 - How to Integrate Google Assistant SDK (Library component) with Android device Android:如何检查Google是否可用? - Android: How to check if Google is available? 如何检查Android设备上的网络何时不可用? - How to check when network is not available on android device? Android:如何检查设备上是否有闪光灯? - Android: how to check the flash light is available on device? 如何以编程方式启动Google智能助理? - How to start Google Assistant programmatically? Android BLE:如何检查绑定的BLE设备是否可用于连接 - Android BLE: How to check if bonded BLE Device is available to connect 如何检查 SIM 卡是否可用于 Android 设备? - How can I check whether the Sim Card is available in an android device? 如何检查android设备是否有录音? - How to check whether the sound recording is available in a android device.?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM