大家好我在尝试将某些信息从我的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¬ifyCircles=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!!!
提前致谢!
答案 0 :(得分:0)
如果您在编写应用活动时遇到调试问题,则应尝试为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¬ifyCircles=false&preview=false&shareOnGooglePlus=true
在请求Google API时,它会确保您的代码中出现的错误。我知道这不是一个答案,但挖掘更多关于错误的信息会更有帮助。响应代码400指出由于语法错误而无法满足请求。