Android 检查谷歌账户档案图片是否已更新

Android 检查谷歌账户档案图片是否已更新,android,google-plus,Android,Google Plus,我正在编写一个Android应用程序,利用用户的个人资料图片。 我想缓存这些图片,并重新下载它们,如果他们已经更新,因为我上次得到他们 我试图实现的基本代码: public foo() { mGoogleApiClient = new GoogleApiClient.Builder(this) .addConnectionCallbacks(this) .addOnConnectionFailedListener(this).addApi(

我正在编写一个Android应用程序,利用用户的个人资料图片。 我想缓存这些图片,并重新下载它们,如果他们已经更新,因为我上次得到他们

我试图实现的基本代码:

public foo() {
    mGoogleApiClient = new GoogleApiClient.Builder(this)
            .addConnectionCallbacks(this)
            .addOnConnectionFailedListener(this).addApi(Plus.API)
            .addScope(Plus.SCOPE_PLUS_LOGIN).build();
    mGoogleApiClient.connect();
}

@Override
public void onConnected(Bundle arg0) {
    try {
        Person currentPerson = Plus.PeopleApi.getCurrentPerson(mGoogleApiClient);
        if (currentPerson != null) {
            String personPhotoUrl = currentPerson.getImage().getUrl();
            // ========================================
            // Here I would like to be able to tell if the image pointed by personPhotoUrl have been updated since
            // the last time I've downloaded it, before I need to re-download it.
            // ========================================               
        } else {
            Toast.makeText(getApplicationContext(),
                    "Person information is null", Toast.LENGTH_LONG).show();
        }
    } catch (Exception e) {
        Toast.makeText(getApplicationContext(), "Identification error, please try again later" , Toast.LENGTH_LONG).show();
    }
}
我测试了一下,当更改个人资料图片时,URL是否也在更改,结果发现没有


有没有办法判断google+个人资料图片是否已更新?

标准缓存ETag或IfModifiedSince是否适用?@Marekserra我认为不支持IfModifiedSince,因为我看不到http头中最后一次修改的内容。ETag可能有用。我将尝试更新。谢谢您确定图像URL没有更改吗?我99%肯定他们会的。也许你得到的图像url被缓存在设备上,一旦同步就会改变。我很肯定,我在更改我的个人资料图片前后用我自己的帐户进行了测试。在两种情况下都得到了相同的URL,并且每次都指向正确的图像。