CurrentAccessTokenExpirationBroadcastReceiver内部的逻辑是什么?

时间:2018-12-10 08:00:50

标签: android facebook facebook-sdk-4.x

查看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);
}

0 个答案:

没有答案