gpt4 book ai didi

android - 将云消息传递 api 添加到 GoogleApiClient 时出现 IllegalArgumentException

转载 作者:塔克拉玛干 更新时间:2023-11-02 07:46:51 26 4
gpt4 key购买 nike

我正在 Android 应用程序中设置 Google Cloud Messaging。一开始,我初始化 GoogleApiClient 以检查 Play 服务是否可用:

mGoogleApiClient = new GoogleApiClient.Builder(this)
.addConnectionCallbacks(this)
.addOnConnectionFailedListener(this)
.build();

尝试运行它会产生IllegalArgumentException: must call addApi() to add at least one API,所以我还需要添加GCM Api,但老实说我在文档中找不到它.像这样的东西:

mGoogleApiClient = new GoogleApiClient.Builder(this)
.addApi(gcm.API) <----- WHAT HERE?
.addConnectionCallbacks(this)
.addOnConnectionFailedListener(this)
.build();

最佳答案

看起来还没有办法将 GoogleApiClient 与 Google Cloud Messaging 结合使用。在那之前,我们需要使用 GooglePlayServicesUtil 方式。

关于android - 将云消息传递 api 添加到 GoogleApiClient 时出现 IllegalArgumentException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30887104/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com