简体   繁体   English

感知 API:com.google.android.gms.common.api.ApiException:15

[英]Awareness API: com.google.android.gms.common.api.ApiException: 15

In my onCreate I call the following function to detect the weather.在我的onCreate我调用以下函数来检测天气。

private void detectWeather() {
        if( !checkLocationPermission() ) {
            return;
        }

        Awareness.getSnapshotClient(this).getWeather()
                .addOnSuccessListener(new OnSuccessListener<WeatherResponse>() {
                    @Override
                    public void onSuccess(WeatherResponse weatherResponse) {
                        Weather weather = weatherResponse.getWeather();
                    }
                })
                .addOnFailureListener(new OnFailureListener() {
                    @Override
                    public void onFailure(@NonNull Exception e) {
                        Log.e("Testing", "Could not get weather: " + e);
                    }
                });
    }

In my Manifest file I have added the following meta data and permissions:在我的清单文件中,我添加了以下元数据和权限:

<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="com.google.android.gms.permission.ACTIVITY_RECOGNITION" />

<meta-data
    android:name="com.google.android.awareness.API_KEY"
    android:value="MYKEY"/>

<meta-data
    android:name="com.google.android.geo.API_KEY"
    android:value="MYKEY"/>

And in my Gradle file I've added the following dependencies.在我的 Gradle 文件中,我添加了以下依赖项。

compile 'com.google.android.gms:play-services:+'
compile 'com.google.android.gms:play-services-gcm:+'
compile 'com.google.android.gms:play-services-location:+'
compile 'com.google.android.gms:play-services-awareness:+'

The app launches fine and gets to the awareness API, however it throws the following error in the log: com.google.android.gms.common.api.ApiException: 15 .该应用程序可以正常启动并访问感知 API,但是它会在日志中引发以下错误: com.google.android.gms.common.api.ApiException: 15 I can't really find the explanation for this error in the documentation nor on Google/Stackoverflow.我在文档和 Google/Stackoverflow 上都找不到对这个错误的解释。 Am I missing something obvious?我错过了一些明显的东西吗?

For future readers, weather and place is now deprecated in the Google Awareness API.对于未来的读者,Google Awareness API 现已弃用天气和地点。

An alternative is the NumberEight SDK , which can do a lot more than Awareness (although no regioning is available at the time of writing).另一种选择是NumberEight SDK ,它可以做的比 Awareness 多得多(尽管在撰写本文时没有可用的区域划分)。

It performs a wide variety of context recognition tasks on both iOS and Android including:它在 iOS 和 Android 上执行各种上下文识别任务,包括:

  • Real-time physical activity detection实时身体活动检测
  • Current place categories当前地点类别
  • Motion detection移动侦测
  • Reachability可达性
  • Local weather当地天气

It can also record user context for reports and analysis via the online portal.它还可以通过在线门户记录用户上下文以进行报告和分析。

To quickly receive weather updates in Java, you would write:要在 Java 中快速接收天气更新,您可以编写:

NumberEight ne = new NumberEight();

ne.onWeatherUpdated(
    new NumberEight.SubscriptionCallback<NEWeather>() {
        @Override
        public void onUpdated(@NonNull Glimpse<NEWeather> glimpse) {
            Log.d("CurrentWeather", glimpse.getMostProbable().toString());
        }
    });

Here are some iOS and Android example projects.以下是一些iOSAndroid示例项目。

Disclosure: I'm one of the developers.披露:我是开发人员之一。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 带有com.google.android.gms.common.api.ApiException的Google Awareness API位置:7508 - Google Awareness API Places with com.google.android.gms.common.api.ApiException: 7508 com.google.android.gms.common.api.ApiException: 10 - com.google.android.gms.common.api.ApiException: 10 异常com.google.android.gms.common.api.ApiException:12500 - Exception com.google.android.gms.common.api.ApiException: 12500 com.google.android.gms.common.api.ApiException: 12500 - com.google.android.gms.common.api.ApiException: 12500 安全网:com.google.android.gms.common.api.ApiException:16: - SAFETYNET : com.google.android.gms.common.api.ApiException: 16: com.google.android.gms.common.api.ApiException: 16: - com.google.android.gms.common.api.ApiException: 16: com.google.android.gms.common.api.ApiException:8: - com.google.android.gms.common.api.ApiException: 8: com.google.android.gms.common.api.ApiException: 10: - com.google.android.gms.common.api.ApiException: 10: com.google.android.gms.common.api.ApiException: 17: API: Drive.API_CONNECTIONLESS 在此设备上不可用 - com.google.android.gms.common.api.ApiException: 17: API: Drive.API_CONNECTIONLESS is not available on this device com.google.android.gms.common.api.ApiException: 10: 调用者未列入白名单以调用此 API - com.google.android.gms.common.api.ApiException: 10: Caller not whitelisted to call this API
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM