gpt4 book ai didi

android - 从 GoogleSignInAccount 获取高质量的个人资料图片

转载 作者:塔克拉玛干 更新时间:2023-11-02 23:57:10 25 4
gpt4 key购买 nike

在我的 Android 应用程序中,为了通过 google 帐户 进行身份验证,我遵循了这个官方教程 https://developers.google.com/identity/sign-in/android/people#retrieve_profile_information_for_a_signed-in_user并且有效。

如那里所述,要检索个人资料图片,我使用“GoogleSignInAccount”类的“getPhotoUrl()”方法。示例:

GoogleSignInResult result = Auth.GoogleSignInApi.getSignInResultFromIntent(data);
GoogleSignInAccount acct = result.getSignInAccount();
String personName = acct.getDisplayName();
String personEmail = acct.getEmail();
String personId = acct.getId();
Uri personPhoto = acct.getPhotoUrl();

问题是我通过此 URL 获得的图像质量很差(小尺寸)。

Screenshot example

我该如何解决这个问题?

最佳答案

如果您的照片网址有 sz=50 键(图片大小为 50 或其他)。然后将大小替换为最高。像 sz=240

我不确定你的照片 url 是否有 sz 键,因为我使用了 Person API,它有 sz 键用于 getUrl() 以获取现已弃用的用户详细信息。

更新: Person.Image -官方文档,其中说明了如何获取不同维度的个人资料头像

The URL of the person's profile photo. To resize the image and crop it to a square, append the query string ?sz=x, where x is the dimension in pixels of each side


然而,正如@stackpic91 所说,新的 API GoogleSignInAccount.getPhotoUrl()S96-c 将其值更改为最高以获得大图像 S240-c

关于android - 从 GoogleSignInAccount 获取高质量的个人资料图片,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36956326/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com