Google Android API PlusClient writeMoment无所作为

Google Android API PlusClient writeMoment无所作为,第1张

概述为了在android应用中实现社交功能,我尝试使用“PlusClient”类的“writeMoment”方法,但没有任何反应.我能够与“PlusClient”成功建立连接,并使用我的应用编写深层链接.这是我打开Goog​​le连接时的代码:monPlusClient=newPlusClient.Builder(this,newGoog

为了在android应用中实现社交功能,我尝试使用“ PlusClIEnt”类的“ writeMoment”方法,但没有任何反应.我能够与“ PlusClIEnt”成功建立连接,并使用我的应用编写深层链接.

这是我打开Goog​​le连接时的代码:

monPlusClIEnt = new PlusClIEnt.Builder(this,            new GooglePlayServicesClIEnt.ConnectionCallbacks() {                @OverrIDe                public voID onConnected() {                    plusencours = false;                    String accountname = monPlusClIEnt.getAccountname();                    // We've resolved any connection errors.                    Toast.makeText(                            ActiviteAfficher.this,                            accountname                                    + " "                                    + ActiviteAfficher.this                                            .getResources()                                            .getString(                                                    R.string.texteconnexion),                            Toast.LENGTH_LONG).show();                    // Log.d(TAG_DEBUG, accountname + " connected");                }                @OverrIDe                public voID ondisconnected() {                    plusencours = false;                    // Log.d(TAG_DEBUG, "disconnected");                }            }, new GooglePlayServicesClIEnt.OnConnectionFailedListener() {                @OverrIDe                public voID onConnectionFailed(ConnectionResult resultat) {                    if (resultat.hasResolution()) {                        try {                            resultat.startResolutionForResult(                                    ActiviteAfficher.this,                                    REQUEST_CODE_RESolVE_ERR);                        } catch (SendIntentException e) {                            plusencours = true;                            monPlusClIEnt.connect();                        }                    }                    // Save the result and resolve the connection failure                    // upon a user click.                    mConnectionResult = resultat;                }            })            .setVisibleActivitIEs("http://schemas.Google.com/AddActivity",                    "http://schemas.Google.com/discoverActivity")            .setScopes(Scopes.PLUS_LOGIN, Scopes.PLUS_PROfile).build();

这是我使用“ writeMoment”时的代码:

ItemScope target = new ItemScope.Builder()                .setID(monSujet.getMID())                .setname(                        monSujet.getname() + " - "                                + monSujet.getNotablename())                .setDescription(dialoguedescription).setimage(urlimage)                .setType("http://schema.org/Person").build();        Moment moment = new Moment.Builder()                .setType("http://schemas.Google.com/AddActivity")                .setTarget(target).build();        if (monPlusClIEnt.isConnected()) {            monPlusClIEnt.writeMoment(moment);        }

对我来说,了解logcat很难:

05-09 12:00:32.380: I/ElegantRequestDirector(27290): I/O exception (org.apache.http.NohttpResponseException) caught when processing request: The target server Failed to respond05-09 12:00:32.380: I/ElegantRequestDirector(27290): retrying request05-09 12:00:33.000: E/Volley(27290): [3428] BasicNetwork.performRequest: Unexpected response code 400 for https://www.GoogleAPIs.com/plus/v1/people/me/moments/vault05-09 12:00:33.050: D/SyncManager(295): Failed sync operation XXXXXXX@gmail.com (com.Google), com.Google.androID.gms.plus.action, USER, earlIEstRunTime 140603923, SyncResult: stats [ numIoExceptions: 1]05-09 12:00:33.050: D/SyncSetupManager(16157): setState: sync = true, wantedSyncState = true05-09 12:00:33.090: D/SyncSetupManager(16157): Enabling sync

解决方法:

如果您在编写应用程序活动时调试问题时遇到问题,则应尝试为GooglePlusPlatform启用调试功能:

adb shell setprop log.tag.GooglePlusPlatform VERBOSE

在此也进行了说明-https://developers.google.com/+/mobile/android/getting-started#frequently_asked_questions

在启用调试的情况下运行代码会将以下内容写入logcat:

D/GooglePlusPlatform(8133): Unexpected response code (400) when requesting: writeMomentD/GooglePlusPlatform(8133): Error response: {D/GooglePlusPlatform(8133):  "error": {D/GooglePlusPlatform(8133):   "errors": [D/GooglePlusPlatform(8133):    {D/GooglePlusPlatform(8133):     "domain": "global",D/GooglePlusPlatform(8133):     "reason": "badRequest",D/GooglePlusPlatform(8133):     "message": "Missing Metadata fIEld: http://schema.org/url."D/GooglePlusPlatform(8133):    }D/GooglePlusPlatform(8133):   ],D/GooglePlusPlatform(8133):   "code": 400,D/GooglePlusPlatform(8133):   "message": "Missing Metadata fIEld: http://schema.org/url."D/GooglePlusPlatform(8133):  }D/GooglePlusPlatform(8133): }

如果不提供具有适当标记(而不是显式名称和描述)的公共目标URL,则不能提供Person对象.使用http://schema.org/Thing而不是http://schema.org/Person运行代码对我来说很有效.

总结

以上是内存溢出为你收集整理的Google Android API PlusClient writeMoment无所作为全部内容,希望文章能够帮你解决Google Android API PlusClient writeMoment无所作为所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1094347.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-28
下一篇 2022-05-28

发表评论

登录后才能评论

评论列表(0条)

保存