谷歌plus个人资料图片网址没有得到
在我的Android应用程序中有谷歌加登录按钮。谷歌加登录在我的应用程序工作正常。我用这个代码来访问谷歌加的个人档案相片谷歌plus个人资料图片网址没有得到
String profileurl=Account.getPhotoUrl().toString();
的URL时,我使用由这种原因,这code.I了错误
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String android.net.Uri.toString()' on a null object reference
我应该怎么做才能的个人资料图片网址谷歌加帐户?
由于错误信息中明确指出,要在空对象上调用的方法“的toString()”,你可以改变你的代码来捕获空实例
if (Account.getPhotoUrl() != null){
String profileurl=Account.getPhotoUrl().toString();
}
,或者确保“getPhotoURL ()”永远不会返回null
看来你帐户为空和你想为什么你越来越null
pointer
exception
来访问空对象这就是价值。所以请尝试像这样得到
GoogleSignInResult result;// its your google result
GoogleSignInAccount acct = result.getSignInAccount();// here your Account value is null
String profileURL = "";
if (acct != null)
profileURL = acct.getPhotoUrl().toString();
你的答案也是正确的。 –
@ User1278谢谢,请订阅我的YouTube频道,以获取更多关于手机的更新(Android&ios)。 ** HTTPS://www.youtube.com/channel/UCA5HRmlkT7bqbO56EIlT0UQ** –
现在错误已经谢谢 –