本文整理匯總了Java中com.facebook.FacebookCallback類的典型用法代碼示例。如果您正苦於以下問題:Java FacebookCallback類的具體用法?Java FacebookCallback怎麽用?Java FacebookCallback使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
FacebookCallback類屬於com.facebook包,在下文中一共展示了FacebookCallback類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: registerSharerCallback
import com.facebook.FacebookCallback; //導入依賴的package包/類
public static void registerSharerCallback(
final int requestCode,
final CallbackManager callbackManager,
final FacebookCallback<Sharer.Result> callback) {
if (!(callbackManager instanceof CallbackManagerImpl)) {
throw new FacebookException("Unexpected CallbackManager, " +
"please use the provided Factory.");
}
((CallbackManagerImpl) callbackManager).registerCallback(
requestCode,
new CallbackManagerImpl.Callback() {
@Override
public boolean onActivityResult(int resultCode, Intent data) {
return handleActivityResult(
requestCode,
resultCode,
data,
getShareResultProcessor(callback));
}
});
}
示例2: uploadAsync
import com.facebook.FacebookCallback; //導入依賴的package包/類
public static synchronized void uploadAsync(
ShareVideoContent videoContent,
String graphNode,
FacebookCallback<Sharer.Result> callback)
throws FileNotFoundException {
if (!initialized) {
registerAccessTokenTracker();
initialized = true;
}
Validate.notNull(videoContent, "videoContent");
Validate.notNull(graphNode, "graphNode");
ShareVideo video = videoContent.getVideo();
Validate.notNull(video, "videoContent.video");
Uri videoUri = video.getLocalUrl();
Validate.notNull(videoUri, "videoContent.video.localUrl");
UploadContext uploadContext = new UploadContext(videoContent, graphNode, callback);
uploadContext.initialize();
pendingUploads.add(uploadContext);
enqueueUploadStart(
uploadContext,
0);
}
示例3: UploadContext
import com.facebook.FacebookCallback; //導入依賴的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();
}
示例4: shareLinkContent
import com.facebook.FacebookCallback; //導入依賴的package包/類
private void shareLinkContent(final ShareLinkContent linkContent,
final FacebookCallback<Sharer.Result> callback) {
final GraphRequest.Callback requestCallback = new GraphRequest.Callback() {
@Override
public void onCompleted(GraphResponse response) {
final JSONObject data = response.getJSONObject();
final String postId = (data == null ? null : data.optString("id"));
ShareInternalUtility.invokeCallbackWithResults(callback, postId, response);
}
};
final Bundle parameters = new Bundle();
this.addCommonParameters(parameters, linkContent);
parameters.putString("message", this.getMessage());
parameters.putString("link", Utility.getUriString(linkContent.getContentUrl()));
parameters.putString("picture", Utility.getUriString(linkContent.getImageUrl()));
parameters.putString("name", linkContent.getContentTitle());
parameters.putString("description", linkContent.getContentDescription());
parameters.putString("ref", linkContent.getRef());
new GraphRequest(
AccessToken.getCurrentAccessToken(),
getGraphPath("feed"),
parameters,
HttpMethod.POST,
requestCallback).executeAsync();
}
示例5: registerCallbackImpl
import com.facebook.FacebookCallback; //導入依賴的package包/類
@Override
protected void registerCallbackImpl (
final CallbackManagerImpl callbackManager,
final FacebookCallback<Result> callback) {
final ResultProcessor resultProcessor = (callback == null)
? null
: new ResultProcessor(callback) {
@Override
public void onSuccess(AppCall appCall, Bundle results) {
callback.onSuccess(new Result(results));
}
};
CallbackManagerImpl.Callback callbackManagerCallback = new CallbackManagerImpl.Callback() {
@Override
public boolean onActivityResult(int resultCode, Intent data) {
return ShareInternalUtility.handleActivityResult(
getRequestCode(),
resultCode,
data,
resultProcessor);
}
};
callbackManager.registerCallback(getRequestCode(), callbackManagerCallback);
}
示例6: registerCallbackImpl
import com.facebook.FacebookCallback; //導入依賴的package包/類
@Override
protected void registerCallbackImpl(
final CallbackManagerImpl callbackManager,
final FacebookCallback<Result> callback) {
final ResultProcessor resultProcessor = (callback == null)
? null
: new ResultProcessor(callback) {
@Override
public void onSuccess(AppCall appCall, Bundle results) {
callback.onSuccess(new Result(results.getString("id")));
}
};
CallbackManagerImpl.Callback callbackManagerCallback = new CallbackManagerImpl.Callback() {
@Override
public boolean onActivityResult(int resultCode, Intent data) {
return ShareInternalUtility.handleActivityResult(
getRequestCode(),
resultCode,
data,
resultProcessor);
}
};
callbackManager.registerCallback(getRequestCode(), callbackManagerCallback);
}
示例7: registerCallback
import com.facebook.FacebookCallback; //導入依賴的package包/類
/**
* Registers a login callback to the given callback manager.
* @param callbackManager The callback manager that will encapsulate the callback.
* @param callback The login callback that will be called on login completion.
*/
public void registerCallback(
final CallbackManager callbackManager,
final FacebookCallback<LoginResult> callback) {
if (!(callbackManager instanceof CallbackManagerImpl)) {
throw new FacebookException("Unexpected CallbackManager, " +
"please use the provided Factory.");
}
((CallbackManagerImpl) callbackManager).registerCallback(
CallbackManagerImpl.RequestCodeOffset.Login.toRequestCode(),
new CallbackManagerImpl.Callback() {
@Override
public boolean onActivityResult(int resultCode, Intent data) {
return LoginManager.this.onActivityResult(
resultCode,
data,
callback);
}
}
);
}
示例8: FacebookHelper
import com.facebook.FacebookCallback; //導入依賴的package包/類
public FacebookHelper(@NonNull FacebookListener facebookListener) {
mListener = facebookListener;
mCallBackManager = CallbackManager.Factory.create();
FacebookCallback<LoginResult> mCallBack = new FacebookCallback<LoginResult>() {
@Override public void onSuccess(LoginResult loginResult) {
mListener.onFbSignInSuccess(loginResult.getAccessToken().getToken(),
loginResult.getAccessToken().getUserId());
}
@Override public void onCancel() {
mListener.onFbSignInFail("User cancelled operation");
}
@Override public void onError(FacebookException e) {
mListener.onFbSignInFail(e.getMessage());
}
};
LoginManager.getInstance().registerCallback(mCallBackManager, mCallBack);
}
示例9: setUpFacebookLoginButton
import com.facebook.FacebookCallback; //導入依賴的package包/類
@OnClick(R.id.fb_login)
public void setUpFacebookLoginButton() {
LoginManager.getInstance().logInWithReadPermissions(this, Arrays.asList("email", "public_profile"));
LoginManager.getInstance().registerCallback(callbackManager, new FacebookCallback<LoginResult>() {
@Override
public void onSuccess(LoginResult loginResult) {
handleFacebookAccessToken(loginResult.getAccessToken());
}
@Override
public void onCancel() {
}
@Override
public void onError(FacebookException error) {
if(!isNetworkConnected()){
Snackbar.make(findViewById(android.R.id.content),"please check internet connection"
,Snackbar.LENGTH_SHORT).show();
}else{
Snackbar.make(findViewById(android.R.id.content),"unexpected error,please try again later"
,Snackbar.LENGTH_SHORT).show();
}
}
});
}
示例10: registerFacebookCallback
import com.facebook.FacebookCallback; //導入依賴的package包/類
protected void registerFacebookCallback() {
LoginManager.getInstance().registerCallback(facebookCallbackManager,
new FacebookCallback<LoginResult>() {
@Override
public void onSuccess(LoginResult loginResult) {
// App code
Log.d(TAG, "Login Success");
handleFacebookAccessToken(loginResult.getAccessToken());
}
@Override
public void onCancel() {
// App code
Log.d(TAG, "Login canceled");
}
@Override
public void onError(FacebookException exception) {
// App code
Log.d(TAG, "Login error");
}
});
}
示例11: setupFacebookLogin
import com.facebook.FacebookCallback; //導入依賴的package包/類
private void setupFacebookLogin() {
mFacebookCallbackManager = CallbackManager.Factory.create();
binding.facebookButton.setReadPermissions("email","public_profile");
// Callback registration
binding.facebookButton.registerCallback(mFacebookCallbackManager, new FacebookCallback<LoginResult>() {
@Override
public void onSuccess(LoginResult loginResult) {
firebaseAuthWithFacebook(loginResult.getAccessToken());
}
@Override
public void onCancel() {
Toast.makeText(ProfileActivity.this, "Facebook Authentication cancelled.", Toast.LENGTH_SHORT).show();
}
@Override
public void onError(FacebookException exception) {
Toast.makeText(ProfileActivity.this, "Facebook Authentication failed.", Toast.LENGTH_SHORT).show();
Timber.e(exception);
}
});
}
示例12: LoginFacebook
import com.facebook.FacebookCallback; //導入依賴的package包/類
public LoginFacebook(LoginButton login, Activity context, PreferencesShared pref, final Intent intent) {
callbackManager = CallbackManager.Factory.create();
this.context = context;
preferencesShared = pref;
login.setReadPermissions(Arrays.asList("public_profile", "user_friends"));
login.registerCallback(callbackManager, new FacebookCallback<LoginResult>() {
@Override
public void onSuccess(LoginResult loginResult) {
//Log.d("facebook", "succes" + loginResult.getAccessToken().getToken() + "id" + loginResult.getAccessToken().getExpires() + "data" + loginResult.getAccessToken().getUserId());
conectedwithFacebook(loginResult.getAccessToken().getToken(),intent);
}
@Override
public void onCancel() {
Log.d("intra","facebook");
}
@Override
public void onError(FacebookException error) {
Log.d("facebook", "error" + error.toString());
}
});
}
示例13: loginResultCallback
import com.facebook.FacebookCallback; //導入依賴的package包/類
public static FacebookCallback<LoginResult> loginResultCallback(final MethodChannel.Result result, final OnLoginSuccessListener onLoginSuccess) {
return new FacebookCallback<LoginResult>() {
@Override
public void onSuccess(LoginResult loginResult) {
onLoginSuccess.onLoginResult(loginResult);
}
@Override
public void onCancel() {
result.error(TAG, "Cancelled", null);
}
@Override
public void onError(FacebookException exception) {
result.error(TAG, exception.getMessage(), null);
}
};
}
示例14: registerCallBackManager
import com.facebook.FacebookCallback; //導入依賴的package包/類
/**
* Register call back manager.
*
* @param activity the activity
*/
private void registerCallBackManager(final Activity activity) {
LoginManager.getInstance()
.registerCallback(mCallbackManager, new FacebookCallback<LoginResult>() {
@Override
public void onSuccess(LoginResult loginResult) {
mLoginResult = loginResult;
getUserProfile(activity);
}
@Override
public void onCancel() {
mFacebookLoginResultCallBack.onFacebookLoginCancel();
}
@Override
public void onError(FacebookException error) {
mFacebookLoginResultCallBack.onFacebookLoginError(error);
}
});
}
示例15: setCallbackToLoginFacebookButton
import com.facebook.FacebookCallback; //導入依賴的package包/類
@Override
public void setCallbackToLoginFacebookButton() {
callbackManager = CallbackManager.Factory.create();
LoginManager.getInstance().registerCallback(callbackManager, new FacebookCallback<LoginResult>() {
@Override
public void onSuccess(LoginResult loginResult) {
Bundle param = new Bundle();
param.putString("fields", "id, email");
facebookLink(loginResult);
}
@Override
public void onCancel() {
}
@Override
public void onError(FacebookException error) {
Logger.logExceptionToFabric(error);
}
});
}