【问题标题】:Posting to Google Plus from Android app从 Android 应用发布到 Google Plus
【发布时间】:2014-03-10 05:09:51
【问题描述】:

大家好,当我尝试将一些信息从我的 Android 应用程序发布到 Google Plus 时遇到问题,我必须分享的代码如下:

public void shareOnGooglePlus(Activity activity, String caption)
{
    PlusShare.Builder builder = new PlusShare.Builder(activity);

    // Set call-to-action metadata.
    builder.addCallToAction(
            "CREATE_ITEM", /** call-to-action button label */
            Uri.parse("http://plus.google.com/pages/create"), /** call-to-action url (for desktop use) */
            "/pages/create" /** call to action deep-link ID (for mobile use), 512 characters or fewer */);

    // Set the content url (for desktop use).
    builder.setContentUrl(Uri.parse("https://plus.google.com/pages/"));
    // Set the target deep-link ID (for mobile use).
    builder.setContentDeepLinkId("/pages/", null, null, null);

    // Set the share text.
    builder.setText(caption);

    activity.startActivityForResult(builder.getIntent(), 0)

}

当按钮共享被按下并显示以下对话框时调用此方法:

然后当我按下分享时,会出现以下对话框:

在 AndroidManifest 我有以下权限:

    <uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.USE_CREDENTIALS" />

还有:

<meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" />

最后在 Android 控制台我发现了以下消息:

    03-10 16:00:51.033    2012-2017/? E/MP-Decision﹕ num online cores: 2 reqd : 3 available : 4 rq_depth:3.300000 hotplug_avg_load_dw: 54
03-10 16:00:51.033    2012-2017/? E/MP-Decision﹕ UP cpu:1 core_idx:1 Nw:1.900000 Tw:140 total_time_up:0.000000
03-10 16:00:51.033    2012-2017/? E/MP-Decision﹕ UP cpu:2 core_idx:2 Nw:2.700000 Tw:90 total_time_up:98.000000
03-10 16:00:51.673    1463-2123/? E/Volley﹕ [90] sm.a: Unexpected response code 400 for https://www.googleapis.com/plus/v1whitelisted/people/me/activities?language=en-AU&notifyCircles=false&preview=false&shareOnGooglePlus=true
03-10 16:00:51.673   1463-18889/? E/InsertActivityOperation﹕ null
    sg
            at sm.a(SourceFile:145)
            at rq.run(SourceFile:105)
03-10 16:00:51.783     696-1212/? E/EnterpriseContainerManager﹕ ContainerPolicy Service is not yet ready!!!

提前致谢!

【问题讨论】:

    标签: android google-plus


    【解决方案1】:

    如果您在编写应用活动时遇到调试问题,您应该尝试为 GooglePlusPlatform 启用调试:

    adb shell setprop log.tag.GooglePlusPlatform VERBOSE
    

    添加后,您将获得以下错误的更多详细信息。

    E/Volley﹕ [90] sm.a: Unexpected response code 400 for https://www.googleapis.com/plus/v1whitelisted/people/me/activities?language=en-AU&notifyCircles=false&preview=false&shareOnGooglePlus=true
    

    它会确保您在向 Google API 请求时在您的代码中做错了什么。我知道这不是答案,但它有助于挖掘更多有关错误的信息。响应代码 400 表示由于语法错误而无法满足请求。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-08-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-02-15
      相关资源
      最近更新 更多