Android - Google+ 分享状态失败

标签 android google-plus google-play-services

我查看了 Google 关于如何将状态从我的 Android 应用程序共享到 Google+ 的说明:https://developers.google.com/+/mobile/android/share/
(我正在做一个示例应用程序,它完全按照示例中的方式执行)

我遇到了这个异常:

Process: com.google.android.gms.ui, PID: 19643
java.lang.IllegalArgumentException
        at com.google.k.a.aj.a(SourceFile:72)
        at com.google.android.gms.plus.audience.a.e.<init>(SourceFile:63)
        at com.google.android.gms.plus.audience.a.e.<init>(SourceFile:53)
        at com.google.android.gms.plus.audience.a.d.<init>(SourceFile:28)
        at com.google.android.gms.plus.sharebox.al.a(SourceFile:213)
        at android.support.v4.app.ax.c(SourceFile:490)
        at android.support.v4.app.ax.d(SourceFile:499)
        at android.support.v4.app.ax.b(SourceFile:646)
        at com.google.android.gms.plus.sharebox.al.a(SourceFile:192)
        at com.google.android.gms.plus.sharebox.ShareBoxActivity.a(SourceFile:525)
        at com.google.android.gms.plus.sharebox.au.a(SourceFile:810)
        at com.google.android.gms.plus.internal.ce.a(SourceFile:214)
        at com.google.android.gms.common.internal.v.d(SourceFile:200)
        at com.google.android.gms.common.internal.u.handleMessage(SourceFile:136)
        at android.os.Handler.dispatchMessage(Handler.java:102)
        at android.os.Looper.loop(Looper.java:135)
        at android.app.ActivityThread.main(ActivityThread.java:5221)
        at java.lang.reflect.Method.invoke(Native Method)
        at java.lang.reflect.Method.invoke(Method.java:372)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)

似乎错误来自“Google Play 服务”,但我不知道为什么?

想法?

最佳答案

我在使用 google-play-services 6.1.71 时看到了同样的错误。上面的 Edu Barbas 有正确的答案,使用 ShareCompat.IntentBuilder 似乎可以解决问题。我没有足够的分数来评论他的回答,但我想补充一点, Intent 的构建和分享 Activity 的开始有点不同:

      Intent shareIntent = ShareCompat.IntentBuilder.from(TheCurrentActivity.this)
                .setType("text/plain")
                .setText(statusMessage)
                .getIntent()
                .setPackage("com.google.android.apps.plus");

        startActivityForResult(shareIntent, 0);

离开 setPackage("com.google.android.apps.plus") 行会出现一个通用的 android 共享对话框,除了 google plus 之外,您还可以通过电子邮件、蓝牙和短信进行共享。添加 setPackage 行允许您绕过该对话框并通过 google plus 独占共享。

关于Android - Google+ 分享状态失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27235268/

相关文章:

android - 无法解析符号 PlusShare

google-plus - 如何查看某个网址在 Google+ 上的分享次数?

google-api - android 上的 G+ 登录抛出 INVALID_CLIENT_ID

java - 谷歌 AdMob java.lang.NoClassDefFoundError : com. google.android.gms.ads.AdView

android - 使用 Delphi 访问 Android 日历

JAVA:如何确保 1 方法在调用下一个方法之前已完成?

android - 通过方向更改保持进度条可见性

android - intent.resolveActivity 在 API 30 中返回 null

iphone - 如何在 IOS SDK 中获取 Google Plus 圈子

Android Play 商店错误 -505