查看CurrentAccessTokenExpirationBroadcastReceiver代码。
/**
* This class is notified when the current {@link AccessToken} has expired.
*/
public final class CurrentAccessTokenExpirationBroadcastReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
if (AccessTokenManager.ACTION_CURRENT_ACCESS_TOKEN_CHANGED.equals(intent.getAction())) {
AccessTokenManager.getInstance().currentAccessTokenChanged();
}
}
}
AccessTokenManager.getInstance().currentAccessTokenChanged();
只会发送意图再次唤醒CurrentAccessTokenExpirationBroadcastReceiver
,这是一个无限循环吗?
void currentAccessTokenChanged() {
sendCurrentAccessTokenChangedBroadcastIntent(
this.currentAccessToken,
this.currentAccessToken);
}
private void sendCurrentAccessTokenChangedBroadcastIntent(AccessToken oldAccessToken,
AccessToken currentAccessToken) {
Intent intent = new Intent(
FacebookSdk.getApplicationContext(),
CurrentAccessTokenExpirationBroadcastReceiver.class);
intent.setAction(ACTION_CURRENT_ACCESS_TOKEN_CHANGED);
intent.putExtra(EXTRA_OLD_ACCESS_TOKEN, oldAccessToken);
intent.putExtra(EXTRA_NEW_ACCESS_TOKEN, currentAccessToken);
localBroadcastManager.sendBroadcast(intent);
}