本文整理汇总了Java中com.facebook.AccessToken.isExpired方法的典型用法代码示例。如果您正苦于以下问题:Java AccessToken.isExpired方法的具体用法?Java AccessToken.isExpired怎么用?Java AccessToken.isExpired使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.facebook.AccessToken
的用法示例。
在下文中一共展示了AccessToken.isExpired方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: isLoggedIn
import com.facebook.AccessToken; //导入方法依赖的package包/类
public boolean isLoggedIn() {
AccessToken accessToken = AccessToken.getCurrentAccessToken();
Log.d("token",accessToken+"");
if (accessToken != null) {
if (!accessToken.isExpired()) {
return true;
}
return false;
}
return false;
}
示例2: getSignedInToken
import com.facebook.AccessToken; //导入方法依赖的package包/类
/**
* @return the Facebook AccessToken when signed-in with a non-expired token.
*/
private AccessToken getSignedInToken() {
final AccessToken accessToken = AccessToken.getCurrentAccessToken();
if (accessToken != null && !accessToken.isExpired()) {
Log.d(LOG_TAG, "Facebook Access Token is OK");
return accessToken;
}
Log.d(LOG_TAG,"Facebook Access Token is null or expired.");
return null;
}
示例3: refreshFacebookCredentials
import com.facebook.AccessToken; //导入方法依赖的package包/类
/**
* Refresh cognito credentials based on identity token previously obtained from Facebook
* @param onCompletion a runnable that will be executed once the credentials have been successfully renewed
*/
private void refreshFacebookCredentials(Runnable onCompletion) {
Log.v(TAG, "Will try to refresh Facebook token as session has expired...");
final AccessToken accessToken = AccessToken.getCurrentAccessToken();
if (!accessToken.isExpired()) {
Log.v(TAG, String.format(" -> Facebook token is not expired (expiration %s)...", SimpleDateFormat.getInstance().format(accessToken.getExpires())));
String token = accessToken.getToken();
Map<String, String> logins = new HashMap<>();
logins.put(FACEBOOK_LOGIN, token);
Log.v(TAG, " -> will refresh login for " + FACEBOOK_LOGIN);
// Refreshing session credentials (must be asynchronous)...
new RefreshTokenTask(onCompletion).execute(logins);
// We use the opportunity to refresh the Facebook token
Date now = new Date();
if (accessToken.getLastRefresh().getTime() < (now.getTime() - 7 * 86400)) {
Log.v(TAG, " -> triggering async facebook token refresh");
AccessToken.refreshCurrentAccessTokenAsync();
}
} else {
Log.v(TAG, String.format(" -> Facebook token is expired (expiration %s)...", SimpleDateFormat.getInstance().format(accessToken.getExpires())));
//User has to sign in to refresh an elapsed facebook token
// TODO onCompletion is ignored (should be dealt with in onActivityResult)
Intent intent = new Intent(this, SignInActivity.class);
this.startActivity(intent);
}
}
示例4: onViewCreated
import com.facebook.AccessToken; //导入方法依赖的package包/类
@Override public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
AccessToken accessToken = AccessToken.getCurrentAccessToken();
if (accessToken != null) {
if (!accessToken.isExpired()) {
changeFacebookState(true);
}
}
}
示例5: isLoggedIn
import com.facebook.AccessToken; //导入方法依赖的package包/类
/**
* Check if user is loggedIn
* @return true id accessToken is not expired, false otherwise.
*/
public boolean isLoggedIn() {
AccessToken accessToken = getAccessToken();
return accessToken != null && !accessToken.isExpired();
}