本文整理汇总了Java中com.facebook.AccessToken.getCurrentAccessToken方法的典型用法代码示例。如果您正苦于以下问题:Java AccessToken.getCurrentAccessToken方法的具体用法?Java AccessToken.getCurrentAccessToken怎么用?Java AccessToken.getCurrentAccessToken使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.facebook.AccessToken
的用法示例。
在下文中一共展示了AccessToken.getCurrentAccessToken方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: UploadContext
import com.facebook.AccessToken; //导入方法依赖的package包/类
private UploadContext(
ShareVideoContent videoContent,
String graphNode,
FacebookCallback<Sharer.Result> callback) {
// Store off the access token right away so that under no circumstances will we
// end up with different tokens between phases. We will rely on the access token tracker
// to cancel pending uploads.
this.accessToken = AccessToken.getCurrentAccessToken();
this.videoUri = videoContent.getVideo().getLocalUrl();
this.title = videoContent.getContentTitle();
this.description = videoContent.getContentDescription();
this.ref = videoContent.getRef();
this.graphNode = graphNode;
this.callback = callback;
this.params = videoContent.getVideo().getParameters();
}
示例2: authorize
import com.facebook.AccessToken; //导入方法依赖的package包/类
void authorize(Request request) {
if (request == null) {
return;
}
if (pendingRequest != null) {
throw new FacebookException("Attempted to authorize while a request is pending.");
}
if (AccessToken.getCurrentAccessToken() != null && !checkInternetPermission()) {
// We're going to need INTERNET permission later and don't have it, so fail early.
return;
}
pendingRequest = request;
handlersToTry = getHandlersToTry(request);
tryNextHandler();
}
示例3: revokePermission
import com.facebook.AccessToken; //导入方法依赖的package包/类
public void revokePermission(final String permission) {
AccessToken token = AccessToken.getCurrentAccessToken();
String uri = "me/permissions/" + permission;
GraphRequest graphRequest = GraphRequest.newDeleteObjectRequest(
token, uri, new GraphRequest.Callback() {
@Override
public void onCompleted(GraphResponse response) {
FacebookRequestError error = response.getError();
if (error == null) {
Utils.d("FB:Revoke:Response:" + response.toString());
getPermissions();
}
}
});
graphRequest.executeAsync();
}
示例4: successLogin
import com.facebook.AccessToken; //导入方法依赖的package包/类
protected void successLogin (FirebaseUser user) {
Utils.d("FB:Login:Success");
isFacebookConnected = true;
accessToken = AccessToken.getCurrentAccessToken();
try {
currentFBUser.put("name", user.getDisplayName());
currentFBUser.put("email_id", user.getEmail());
currentFBUser.put("photo_uri", user.getPhotoUrl());
currentFBUser.put("token", accessToken.getToken().toString());
} catch (JSONException e) { Utils.d("FB:JSON:Error:" + e.toString()); }
getPermissions();
// call Script
Utils.callScriptFunc("Auth", "FacebookLogin", "true");
}
示例5: loadRequests
import com.facebook.AccessToken; //导入方法依赖的package包/类
public void loadRequests() {
AccessToken token = AccessToken.getCurrentAccessToken();
GraphRequest myRequests = GraphRequest.newGraphPathRequest(
token, "/me/apprequests", new GraphRequest.Callback() {
@Override
public void onCompleted(GraphResponse response) {
FacebookRequestError error = response.getError();
if (error == null) {
JSONObject graphObject = response.getJSONObject();
JSONArray data = graphObject.optJSONArray("data");
Utils.callScriptFunc("pendingRequest", data.toString());
} else { Utils.d("Response Error: " + error.toString()); }
}
});
myRequests.executeAsync();
}
示例6: deleteRequest
import com.facebook.AccessToken; //导入方法依赖的package包/类
public static void deleteRequest (String requestId) {
// delete Requets here GraphAPI.
Utils.d("Deleting:Request:" + requestId);
AccessToken token = AccessToken.getCurrentAccessToken();
GraphRequest graphRequest = GraphRequest.newDeleteObjectRequest(
token, requestId, new GraphRequest.Callback() {
@Override
public void onCompleted(GraphResponse response) {
FacebookRequestError error = response.getError();
if (error == null) { Utils.d("OnDelete:Req:" + response.toString()); }
}
});
graphRequest.executeAsync();
}
示例7: getUserDataFromRequest
import com.facebook.AccessToken; //导入方法依赖的package包/类
public static void getUserDataFromRequest (String requestId) {
// Grah Api to get user data from request.
AccessToken token = AccessToken.getCurrentAccessToken();
GraphRequest graphRequest = GraphRequest.newGraphPathRequest(
token, requestId, new GraphRequest.Callback() {
@Override
public void onCompleted(GraphResponse response) {
FacebookRequestError error = response.getError();
if (error == null) { Utils.d("Response: " + response.toString()); }
else { Utils.d("Error: " + response.toString()); }
}
});
graphRequest.executeAsync();
}
示例8: initUserProfile
import com.facebook.AccessToken; //导入方法依赖的package包/类
public void initUserProfile(final IOperationFinishWithDataCallback profileFetched, boolean isForceUpdate) {
if (userProfile != null && !isForceUpdate) {
profileFetched.operationFinished(userProfile);
} else if (!isLogedIn()) {
userProfile = new UserProfile();
profileFetched.operationFinished(userProfile);
} else {
if (AccessToken.getCurrentAccessToken() != null) {
fetchFacebookUserData(profileFetched);
} else if (Twitter.getSessionManager().getActiveSession() != null) {
fetchTwitterUserData(profileFetched);
} else if (VKSdk.isLoggedIn()) {
fetchVkUserData(profileFetched);
}
}
}
示例9: endSession
import com.facebook.AccessToken; //导入方法依赖的package包/类
@Override
public void endSession() {
if (AccessToken.getCurrentAccessToken() != null) {
LoginManager.getInstance().logOut();
}
TwitterSession twitterSession = TwitterCore.getInstance().getSessionManager().getActiveSession();
if (twitterSession != null) {
clearCookies(getApplicationContext());
Twitter.getSessionManager().clearActiveSession();
Twitter.logOut();
}
startActivity(LoginActivity.makeIntent(this));
finish();
}
示例10: onCreate
import com.facebook.AccessToken; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_splash_screen);
Class startClass;
if(AccessToken.getCurrentAccessToken() == null) {
startClass = FacebookLoginActivity.class;
} else {
startClass = TabbedActivity.class;
}
Intent intent = new Intent(this, startClass);
startActivity(intent);
finish();
}
示例11: completeAndValidate
import com.facebook.AccessToken; //导入方法依赖的package包/类
void completeAndValidate(Result outcome) {
// Do we need to validate a successful result (as in the case of a reauth)?
if (outcome.token != null && AccessToken.getCurrentAccessToken() != null) {
validateSameFbidAndFinish(outcome);
} else {
// We're done, just notify the listener.
complete(outcome);
}
}
示例12: AppEventsLogger
import com.facebook.AccessToken; //导入方法依赖的package包/类
/**
* Constructor is private, newLogger() methods should be used to build an instance.
*/
private AppEventsLogger(Context context, String applicationId, AccessToken accessToken) {
Validate.notNull(context, "context");
this.contextName = Utility.getActivityName(context);
if (accessToken == null) {
accessToken = AccessToken.getCurrentAccessToken();
}
// If we have a session and the appId passed is null or matches the session's app ID:
if (accessToken != null &&
(applicationId == null || applicationId.equals(accessToken.getApplicationId()))
) {
accessTokenAppId = new AccessTokenAppIdPair(accessToken);
} else {
// If no app ID passed, get it from the manifest:
if (applicationId == null) {
applicationId = Utility.getMetadataApplicationId(context);
}
accessTokenAppId = new AccessTokenAppIdPair(null, applicationId);
}
synchronized (staticLock) {
if (applicationContext == null) {
applicationContext = context.getApplicationContext();
}
}
initializeTimersIfNeeded();
}
示例13: isPermissionGiven
import com.facebook.AccessToken; //导入方法依赖的package包/类
public boolean isPermissionGiven (final String permission) {
Utils.d("FB:Checking:Available:Permissions:For: " + permission);
accessToken = AccessToken.getCurrentAccessToken();
if (accessToken == null && accessToken.isExpired()) {
Utils.d("FB:Token:NotValid");
return false;
}
return (mUserPermissions.contains(permission));
}
示例14: publishStory
import com.facebook.AccessToken; //导入方法依赖的package包/类
private void publishStory(final String message) {
if (AccessToken.getCurrentAccessToken() != null) {
Bundle postParams = new Bundle();
postParams.putString("message", message);
GraphRequest.Callback callback = new GraphRequest.Callback() {
@Override
public void onCompleted(GraphResponse graphResponse) {
FacebookRequestError error = graphResponse.getError();
if (error != null) {
if (eventHandler != null) {
Log.sysOut("$#$#$ " + error);
eventHandler.stopProgress();
eventHandler.onFacebookError(error
.getErrorMessage());
}
return;
}
if (eventHandler != null) {
eventHandler.stopProgress();
eventHandler.onRecievePost(message);
}
}
};
GraphRequest request = new GraphRequest(AccessToken.getCurrentAccessToken(), "feed", postParams,
HttpMethod.POST, callback);
request.executeAsync();
} else if (eventHandler != null) eventHandler.onFacebookError(activity.getString(R.string.facebook_you_must_login_first_toast));
}
示例15: logout
import com.facebook.AccessToken; //导入方法依赖的package包/类
public void logout() {
setAuthToken(null);
SharedPreferences settings = context.getSharedPreferences(CONSTANT_PREF_FILE, Context.MODE_PRIVATE);
settings.edit().clear().commit();
// MySharedPreferences.wipe(preferences);
if (MySharedPreferences.getUserId(preferences)!= null){
Toast.makeText(context, "userID", Toast.LENGTH_LONG).show();
}
if (AccessToken.getCurrentAccessToken() != null){
LoginManager.getInstance().logOut();
}
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
SharedPreferences.Editor editor = prefs.edit();
editor.clear();
editor.commit();
Intent loginIntent = new Intent(context, RegisterActivity.class);
loginIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(loginIntent);
}