本文整理汇总了Java中com.facebook.share.Sharer类的典型用法代码示例。如果您正苦于以下问题:Java Sharer类的具体用法?Java Sharer怎么用?Java Sharer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Sharer类属于com.facebook.share包,在下文中一共展示了Sharer类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: registerSharerCallback
import com.facebook.share.Sharer; //导入依赖的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));
}
});
}
开发者ID:eviltnan,项目名称:kognitivo,代码行数:23,代码来源:ShareInternalUtility.java
示例2: uploadAsync
import com.facebook.share.Sharer; //导入依赖的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);
}
开发者ID:eviltnan,项目名称:kognitivo,代码行数:27,代码来源:VideoUploader.java
示例3: UploadContext
import com.facebook.share.Sharer; //导入依赖的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();
}
开发者ID:eviltnan,项目名称:kognitivo,代码行数:17,代码来源:VideoUploader.java
示例4: uploadAsync
import com.facebook.share.Sharer; //导入依赖的package包/类
public static synchronized void uploadAsync(
ShareVideoContent videoContent,
String targetId,
FacebookCallback<Sharer.Result> callback)
throws FileNotFoundException {
if (!initialized) {
registerAccessTokenTracker();
initialized = true;
}
Validate.notNull(videoContent, "videoContent");
Validate.notNull(targetId, "targetId");
ShareVideo video = videoContent.getVideo();
Validate.notNull(video, "videoContent.video");
Uri videoUri = video.getLocalUrl();
Validate.notNull(videoUri, "videoContent.video.localUrl");
UploadContext uploadContext = new UploadContext(videoContent, targetId, callback);
uploadContext.initialize();
pendingUploads.add(uploadContext);
enqueueUploadStart(
uploadContext,
0);
}
开发者ID:yudiandreanp,项目名称:SocioBlood,代码行数:27,代码来源:VideoUploader.java
示例5: invokeCallbackWithException
import com.facebook.share.Sharer; //导入依赖的package包/类
public static void invokeCallbackWithException(
FacebookCallback<Sharer.Result> callback,
final Exception exception) {
if (exception instanceof FacebookException) {
invokeOnErrorCallback(callback, (FacebookException) exception);
return;
}
invokeCallbackWithError(
callback,
"Error preparing share content: " + exception.getLocalizedMessage());
}
开发者ID:eviltnan,项目名称:kognitivo,代码行数:12,代码来源:ShareInternalUtility.java
示例6: invokeCallbackWithResults
import com.facebook.share.Sharer; //导入依赖的package包/类
public static void invokeCallbackWithResults(
FacebookCallback<Sharer.Result> callback,
final String postId,
final GraphResponse graphResponse) {
FacebookRequestError requestError = graphResponse.getError();
if (requestError != null) {
String errorMessage = requestError.getErrorMessage();
if (Utility.isNullOrEmpty(errorMessage)) {
errorMessage = "Unexpected error sharing.";
}
invokeOnErrorCallback(callback, graphResponse, errorMessage);
} else {
invokeOnSuccessCallback(callback, postId);
}
}
开发者ID:eviltnan,项目名称:kognitivo,代码行数:16,代码来源:ShareInternalUtility.java
示例7: invokeOnSuccessCallback
import com.facebook.share.Sharer; //导入依赖的package包/类
static void invokeOnSuccessCallback(
FacebookCallback<Sharer.Result> callback,
String postId) {
logShareResult(AnalyticsEvents.PARAMETER_SHARE_OUTCOME_SUCCEEDED, null);
if (callback != null) {
callback.onSuccess(new Sharer.Result(postId));
}
}
开发者ID:eviltnan,项目名称:kognitivo,代码行数:9,代码来源:ShareInternalUtility.java
示例8: invokeOnErrorCallback
import com.facebook.share.Sharer; //导入依赖的package包/类
static void invokeOnErrorCallback(
FacebookCallback<Sharer.Result> callback,
GraphResponse response,
String message) {
logShareResult(AnalyticsEvents.PARAMETER_SHARE_OUTCOME_ERROR, message);
if (callback != null) {
callback.onError(new FacebookGraphResponseException(response, message));
}
}
开发者ID:eviltnan,项目名称:kognitivo,代码行数:10,代码来源:ShareInternalUtility.java
示例9: getDialog
import com.facebook.share.Sharer; //导入依赖的package包/类
@Override
protected FacebookDialogBase<ShareContent, Sharer.Result> getDialog() {
final ShareDialog dialog;
if (ShareButton.this.getFragment() != null) {
dialog = new ShareDialog(ShareButton.this.getFragment() , getRequestCode());
} else {
dialog = new ShareDialog(getActivity(), getRequestCode());
}
return dialog;
}
开发者ID:eviltnan,项目名称:kognitivo,代码行数:11,代码来源:ShareButton.java
示例10: getDialog
import com.facebook.share.Sharer; //导入依赖的package包/类
@Override
protected FacebookDialogBase<ShareContent, Sharer.Result> getDialog() {
final MessageDialog dialog;
if (SendButton.this.getFragment() != null) {
dialog = new MessageDialog(SendButton.this.getFragment() , getRequestCode());
} else {
dialog = new MessageDialog(getActivity(), getRequestCode());
}
return dialog;
}
开发者ID:eviltnan,项目名称:kognitivo,代码行数:11,代码来源:SendButton.java
示例11: shareLinkOnFacebook
import com.facebook.share.Sharer; //导入依赖的package包/类
/**
* Share content on facebook wall
*
* @param activity the activity
* @param callback the callback to receive a result of this share
* @param url the url you wish to share
* @param quote the text you wish to associate with the url shared
*/
private void shareLinkOnFacebook(@NonNull final Activity activity, @NonNull final FacebookShareResultCallback callback, @NonNull String url, @Nullable String quote) {
ShareDialog shareDialog = new ShareDialog(activity);
shareDialog.registerCallback(mCallbackManager, new FacebookCallback<Sharer.Result>() {
@Override
public void onSuccess(Sharer.Result result) {
callback.onFacebookShareSuccess(result);
}
@Override
public void onCancel() {
callback.onFacebookShareCancel();
}
@Override
public void onError(FacebookException error) {
callback.onFacebookShareError(error);
}
}, RC_FACEBOOK_SHARE);
if (ShareDialog.canShow(ShareLinkContent.class)) {
ShareLinkContent linkContent = new ShareLinkContent.Builder().setContentUrl(Uri.parse(url))
.setQuote(quote)
.build();
shareDialog.show(linkContent);
} else {
callback.onFacebookShareCannotShowDialog();
}
}
开发者ID:davideas,项目名称:AndroidBlueprints,代码行数:39,代码来源:FacebookHelper.java
示例12: setUpShareConfig
import com.facebook.share.Sharer; //导入依赖的package包/类
private void setUpShareConfig(String url, ShareDialog shareDialog) {
if (ShareDialog.canShow(ShareLinkContent.class)) {
ShareLinkContent shareLinkContent = new ShareLinkContent.Builder()
.setContentUrl(Uri.parse(url))
.build();
shareDialog.registerCallback(callbackManager, new FacebookCallback<Sharer.Result>() {
@Override
public void onSuccess(Sharer.Result result) {
if (onFacebookShareEvent != null) {
onFacebookShareEvent.onShareSuccessFacebook();
}
}
@Override
public void onCancel() {
if (onFacebookShareEvent != null) {
onFacebookShareEvent.onShareCanceledFacebook();
}
}
@Override
public void onError(FacebookException error) {
error.printStackTrace();
}
});
shareDialog.show(shareLinkContent);
}
}
开发者ID:harrylefit,项目名称:eazysocial,代码行数:30,代码来源:FacebookManager.java
示例13: initFB
import com.facebook.share.Sharer; //导入依赖的package包/类
private void initFB() {
FacebookSdk.sdkInitialize(mContext);
callbackManager = CallbackManager.Factory.create();
mShareDialog = new ShareDialog(mContext);
// this part is optional
mShareDialog.registerCallback(callbackManager, new FacebookCallback<Sharer.Result>() {
@Override
public void onSuccess(Sharer.Result result) {
}
@Override
public void onCancel() {
}
@Override
public void onError(FacebookException error) {
}
});
}
开发者ID:chillcoding-at-the-beach,项目名称:bachamada,代码行数:23,代码来源:FacebookShare.java
示例14: invokeOnSuccessCallback
import com.facebook.share.Sharer; //导入依赖的package包/类
private static void invokeOnSuccessCallback(
FacebookCallback<Sharer.Result> callback,
String postId) {
logShareResult(AnalyticsEvents.PARAMETER_SHARE_OUTCOME_SUCCEEDED, null);
if (callback != null) {
callback.onSuccess(new Sharer.Result(postId));
}
}
开发者ID:CE-KMITL-OOAD-2015,项目名称:Move-Alarm_ORCA,代码行数:9,代码来源:ShareInternalUtility.java
示例15: invokeOnErrorCallback
import com.facebook.share.Sharer; //导入依赖的package包/类
private static void invokeOnErrorCallback(
FacebookCallback<Sharer.Result> callback,
GraphResponse response,
String message) {
logShareResult(AnalyticsEvents.PARAMETER_SHARE_OUTCOME_ERROR, message);
if (callback != null) {
callback.onError(new FacebookGraphResponseException(response, message));
}
}
开发者ID:CE-KMITL-OOAD-2015,项目名称:Move-Alarm_ORCA,代码行数:10,代码来源:ShareInternalUtility.java
示例16: onSuccess
import com.facebook.share.Sharer; //导入依赖的package包/类
@Override
public void onSuccess(Sharer.Result result) {
if (result.getPostId() != null) {
String title = getString(R.string.success);
String id = result.getPostId();
String alertMessage = getString(R.string.successfully_posted_post, id);
showResult(title, alertMessage);
}
}
开发者ID:JimRoid,项目名称:EasyFacebook,代码行数:10,代码来源:BaseLoginActivity.java
示例17: onCreateView
import com.facebook.share.Sharer; //导入依赖的package包/类
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(getLayoutId(), null);
ButterKnife.bind(this, view);
shareDialog = new ShareDialog(this);
CallbackManager callbackManager = CallbackManager.Factory.create();
shareDialog.registerCallback(callbackManager, new FacebookCallback<Sharer.Result>() {
@Override
public void onSuccess(Sharer.Result result) {
}
@Override
public void onCancel() {
}
@Override
public void onError(FacebookException error) {
TextToast.shortShow(getString(R.string.share_fail));
}
});
pager.setOnPageChangeListener(this);
pager.setOnRefreshListener(new PullToRefreshBase.OnRefreshListener<ViewPager>() {
@Override
public void onRefresh(PullToRefreshBase<ViewPager> refreshView) {
refresh();
}
});
adapter = new FragmentAdapter(getChildFragmentManager(), new ArrayList<AbsBaseFragment>());
pager.setAdapter(adapter);
init();
instance=this;
return view;
}
开发者ID:Uphie,项目名称:ONE-Unofficial,代码行数:37,代码来源:AbsModuleFragment.java
示例18: onShareResult
import com.facebook.share.Sharer; //导入依赖的package包/类
public void onShareResult(){
FacebookSdk.sdkInitialize(getApplicationContext());
callbackManager = CallbackManager.Factory.create();
final ShareDialog shareDialog = new ShareDialog(this);
shareDialog.registerCallback(callbackManager, new FacebookCallback<Sharer.Result>() {
@Override
public void onSuccess(Sharer.Result result) {
}
@Override
public void onError(FacebookException error) {
}
@Override
public void onCancel() {
}
});
if (shareDialog.canShow(ShareLinkContent.class)) {
String link = "http://203.151.92.187:8080/courseSchedule?username=" + SingletonID.getInstance().getUserName();
ShareLinkContent linkContent = new ShareLinkContent.Builder()
.setContentTitle("CE SMART TRACKER")
.setContentDescription("วิชาที่เรียน")
.setContentUrl(Uri.parse(link))
.build();
shareDialog.show(linkContent);
}
else Toast.makeText(getApplicationContext(),"ลงทะเบียนผ่าน Facebook",Toast.LENGTH_SHORT).show();
}
开发者ID:CE-KMITL-OOAD-2015,项目名称:CE-SMART-TRACKER-DEV,代码行数:34,代码来源:MyCourseActivity.java
示例19: shareOnFacebook
import com.facebook.share.Sharer; //导入依赖的package包/类
/**
* Shares the app on Facebook
*/
private void shareOnFacebook() {
analytics.sendEvent("facebook", "attempt_post");
// Set up all of the info
ShareLinkContent content = new ShareLinkContent.Builder()
.setContentTitle(getString(R.string.social_facebook_title, "Android"))
.setContentDescription(getString(R.string.social_facebook_description_android))
.setContentUrl(Uri.parse(getString(R.string.social_link_android)))
.setImageUrl(Uri.parse(getString(R.string.social_facebook_image)))
.build();
// Show the dialog
ShareDialog dialog = new ShareDialog(this);
dialog.registerCallback(facebookCallbackManager, new FacebookCallback<Sharer.Result>() {
@Override
public void onSuccess(Sharer.Result result) {
if (result.getPostId() != null) {
// Let the user know they posted successfully
Utils.toast(DrawerActivity.this, R.string.social_post_success);
analytics.sendEvent("facebook", "successful_post");
} else {
Timber.i("Facebook post cancelled");
}
}
@Override
public void onCancel() {
Timber.i("Facebook post cancelled");
}
@Override
public void onError(FacebookException e) {
Timber.e(e, "Error posting to Facebook");
Utils.toast(DrawerActivity.this, R.string.social_post_failure);
analytics.sendEvent("facebook", "failed_post");
}
});
dialog.show(content);
}
开发者ID:jguerinet,项目名称:MyMartlet,代码行数:43,代码来源:DrawerActivity.java
示例20: UploadContext
import com.facebook.share.Sharer; //导入依赖的package包/类
private UploadContext(
ShareVideoContent videoContent,
String targetId,
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.targetId = targetId;
this.callback = callback;
}
开发者ID:yudiandreanp,项目名称:SocioBlood,代码行数:16,代码来源:VideoUploader.java
注:本文中的com.facebook.share.Sharer类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论