- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我想将我的 xamarin Android 应用程序与 Google Play 服务排行榜和成就相集成。我不知道如何从 android documentation 转换以下代码到 c#。
// Create the Google Api Client with access to the Play Game and Drive services.
mGoogleApiClient = new GoogleApiClient.Builder(this)
.addConnectionCallbacks(this)
.addOnConnectionFailedListener(this)
.addApi(Games.API).addScope(Games.SCOPE_GAMES)
.addApi(Drive.API).addScope(Drive.SCOPE_APPFOLDER) // Drive API
.build();
// ...
我尝试转换如下内容
GoogleApiClient api = new GoogleApiClient.Builder(this)
.AddApi(Android.Gms.Games.API)
.Build();
在“Android.Gms.Games.API”下出现错误
this 中没有提到任何事情堆栈溢出线程正在工作。看起来这些东西中的大部分都已弃用。
请建议是否有任何其他可与排行榜集成的简单方法。
编辑:进行了更改,现在出现以下错误。
最佳答案
您将能够通过以下方式访问 GoogleClientAPI
:
var googleClientAPI = new GoogleApiClient.Builder(Application.Context).AddApi(XXX).Build();
var client = new GoogleApiClient.Builder(Application.Context)
.AddApi(GamesClass.API)
.AddScope(GamesClass.ScopeGames)
.Build();
Task.Run(() => {
client.BlockingConnect();
System.Diagnostics.Debug.WriteLine(client.IsConnected);
});
由于您需要访问排行榜和成就,请确保您已添加包:
Xamarin.GooglePlayServices.Games
Xamarin.GooglePlayServices.Identity
这些将自动包含 .Base
和 .Basement
包
using Android.Gms.Common.Apis;
using Android.Gms.Games.LeaderBoard;
using Android.Gms.Games.Achievement;
关于c# - 如何在 Xamarin 中获取 GoogleApiClient 实例?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37233100/
当我尝试从 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 和其他一些小部件时,我得到了一个
我是一名优秀的程序员,十分优秀!