- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试在我的游戏中实现排行榜。我写了这段代码:
GoogleApiClient mGoogleApiClient;
mGoogleApiClient = new GoogleApiClient.Builder(this)
.addApi(Drive.API)
.addScope(Drive.SCOPE_FILE)
.build();
mGoogleApiClient.connect();
//....
while(!mGoogleApiClient.isConnected())Log.d("","NO CONNECTED");
Games.Leaderboards.submitScore(mGoogleApiClient, "MY_LEADERBOARD_ID",newscore);
为什么 mGoogleApiClient.isConnected()
总是返回 false?
EDIT1:好的,现在可以使用了(我已经将 Drive.API
更改为 Games.API
并将 Drive.SCOPE_FILE
更改为 Games.SCOPE_GAME
) 但当我调用 submitScore()
时,即使在日志中一切正常,排行榜仍然是空的。我如何检查 submitScore()
是否真的有效?
EDIT2:我用过
startActivityForResult(Games.Leaderboards.getLeaderboardIntent(mGoogleApiClient, "MY_LEADERBOARD_ID"), REQ_LEADERBOARD);
一切正常!
最佳答案
您需要向构建器(或 GoogleApiClient)添加几个回调监听器。最有可能发生的情况是登录失败,因为您还没有权限。您需要处理该故障,以便用户可以授权您的应用。
关于android - GoogleApiClient.isConnected() 总是返回 false,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21966198/
当我尝试从 GoogleApiClient 注销时,收到以下错误消息 GoogleApiClient.isConnected() on a null object reference 这是我的代码:
所以我发现了一些关于 GoogleApiClient 对我来说不是很清楚的东西。GoogleApiClient 有一个名为 onConnected 的函数,该函数在客户端已连接(肯定)时运行。 我得到
我在这里查看了这个问答:GoogleApiClient is throwing "GoogleApiClient is not connected yet" AFTER onConnected fun
我正在尝试在服务中实现 Fused Location API。我已经完成了以下编码,但出现如下错误: java.lang.RuntimeException: Unable to instantia
我想在android中实现自动完成位置google API。为此,我需要创建一个 GoogleApiClient 对象。我为此使用了以下代码... private GoogleApiClient mG
我创建了一个名为 SendToWear 的类,其中包含一个名为 sendMessage(Context context, String path, @Nullable String data) 的静态
我想获取设备的当前位置,这是我的一段代码 private void displayLocation() { mLastLocation = LocationServices.FusedLoca
我的场景是我希望有一个服务定期获取一些信息(例如用户的位置),将其报告到我的服务器并在该位置与某个 X 位置匹配时接收推送通知。 无论应用程序是否正在运行,我都希望得到一些关于定期检索位置信息的最佳机
我正在将 Google Smart Lock 实现到一个应用程序中,之前我在构建 Api 客户端时没有遇到任何问题。事实上,我正在完成一些语法更改并清理代码(甚至没有触及初始化 Api 客户端的代码)
这是我尝试实例化它的代码: gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
我在我的应用程序上使用 Google+ 登录,并遵循了诸如 Getting Started 之类的引用和 Google+ Sign-in for Android . 所以情况是这样的: 我有一个 Lo
我正在编写一个 Android Wear 应用,我想让可穿戴设备在点击按钮时在手机上启动一个 Intent。 为此,我首先像这样设置与 GoogleApiClient 的连接 googleApiCl
我想使用 FusedLocationProviderApi 获取最后的已知位置。我按照谷歌教程所说的那样做了,但似乎 GoogleApiClient 没有连接,至少它没有触发 onConnected
我正在处理的应用程序有时可以正常工作,但有时会出现此错误 FATAL EXCEPTION: java.lang.RuntimeException: Unable to pause activity {
我正在为我的项目使用 Google App Indexing。 此功能的新手。我只是遵循谷歌指南。 Notify the google using API 在此页面中,要求创建一个 GoogleApi
我通过 GoogleApiClient 为应用设置了 google plus 登录。 每当应用程序首次安装并尝试通过 GoogleApiClient 建立连接时,它永远不会成功,并且总是以 onCon
我正在尝试获取服务中的位置更新信息。为此,我创建了一个服务,并在服务类的 onStartCommand 中创建了 GoogleApiClient,但我没有在服务中收到连接回调。请帮助解决这个问题。 下
更新用户的当前位置我在我的项目中实现了以下方法: GoogleApiClient.ConnectionCallbacks, GoogleApiClient.OnConnectionFailedList
我正在尝试为我的 Android 游戏使用 Google Games 回合制 Api。我用来连接 GoogleApiClient 的代码来自 Google 的 Api 示例或文档。 在我的 onCon
我尝试学习 android 开发,现在我正在开发一个具有融合位置服务的应用程序。 当我想放置 GoogleMap fragment 、带有经纬度的 Textviews 和其他一些小部件时,我得到了一个
我是一名优秀的程序员,十分优秀!