我正在编写一个使用用户个人资料图片的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();
}
}
我测试过看,如果在更改个人资料图片时,网址也在变化,并且发现它没有。
有没有办法判断Google +个人资料图片是否已更新?