本文整理汇总了Java中com.facebook.share.model.ShareLinkContent类的典型用法代码示例。如果您正苦于以下问题:Java ShareLinkContent类的具体用法?Java ShareLinkContent怎么用?Java ShareLinkContent使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ShareLinkContent类属于com.facebook.share.model包,在下文中一共展示了ShareLinkContent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: compartir
import com.facebook.share.model.ShareLinkContent; //导入依赖的package包/类
/**
* Metodo para compartir en Facebook
* @param titulo Titulo de lo que se va a compartir
* @param contenido Contenido que se comparte
*/
private void compartir(String titulo, String contenido){
//Comprobamos si se puede mostrar el ShareDialog
if (ShareDialog.canShow(ShareLinkContent.class)) {
//Creamos el contenido
ShareLinkContent linkContent = new ShareLinkContent.Builder()
//Le asignamos el titulo
.setContentTitle(titulo)
//Le asignamos una imagen para mostrar que subimos a internete
.setImageUrl(Uri.parse("http://s2.postimg.org/m7kf0y8zt/565px_Mastermind.jpg"))
//Un enlace al que se accederia clickando en Facebook
.setContentUrl(Uri.parse("https://play.google.com/store"))
//Le asignamos el contenido que se quiere compartir
.setContentDescription(contenido)
//Lo construimos
.build();
//Mostramos la pantalla de compartir con lo creado anteriormente
shareDialog.show(linkContent);
}
}
示例2: createForFeed
import com.facebook.share.model.ShareLinkContent; //导入依赖的package包/类
public static Bundle createForFeed(ShareLinkContent shareLinkContent) {
Bundle webParams = new Bundle();
Utility.putNonEmptyString(
webParams,
ShareConstants.WEB_DIALOG_PARAM_NAME,
shareLinkContent.getContentTitle());
Utility.putNonEmptyString(
webParams,
ShareConstants.WEB_DIALOG_PARAM_DESCRIPTION,
shareLinkContent.getContentDescription());
Utility.putNonEmptyString(
webParams,
ShareConstants.WEB_DIALOG_PARAM_LINK,
Utility.getUriString(shareLinkContent.getContentUrl()));
Utility.putNonEmptyString(
webParams,
ShareConstants.WEB_DIALOG_PARAM_PICTURE,
Utility.getUriString(shareLinkContent.getImageUrl()));
return webParams;
}
示例3: validate
import com.facebook.share.model.ShareLinkContent; //导入依赖的package包/类
private static void validate(ShareContent content, Validator validator)
throws FacebookException {
if (content == null) {
throw new FacebookException("Must provide non-null content to share");
}
if (content instanceof ShareLinkContent) {
validator.validate((ShareLinkContent) content);
} else if (content instanceof SharePhotoContent) {
validator.validate((SharePhotoContent) content);
} else if (content instanceof ShareVideoContent) {
validator.validate((ShareVideoContent) content);
} else if (content instanceof ShareOpenGraphContent) {
validator.validate((ShareOpenGraphContent) content);
}
}
示例4: startShareOnFacebook
import com.facebook.share.model.ShareLinkContent; //导入依赖的package包/类
private void startShareOnFacebook(final @NonNull Project project) {
if (!ShareDialog.canShow(ShareLinkContent.class)) {
return;
}
final Photo photo = project.photo();
final ShareOpenGraphObject object = new ShareOpenGraphObject.Builder()
.putString("og:type", "kickstarter:project")
.putString("og:title", project.name())
.putString("og:description", project.blurb())
.putString("og:image", photo == null ? null : photo.small())
.putString("og:url", project.webProjectUrl())
.build();
final ShareOpenGraphAction action = new ShareOpenGraphAction.Builder()
.setActionType("kickstarter:back")
.putObject("project", object)
.build();
final ShareOpenGraphContent content = new ShareOpenGraphContent.Builder()
.setPreviewPropertyName("project")
.setAction(action)
.build();
this.shareDialog.show(content);
}
示例5: shareOnFacebook
import com.facebook.share.model.ShareLinkContent; //导入依赖的package包/类
private void shareOnFacebook() {
facebookCallbackManager = CallbackManager.Factory.create();
ShareDialog shareDialog = new ShareDialog(this);
if (ShareDialog.canShow(ShareLinkContent.class)) {
ShareLinkContent linkContent = new ShareLinkContent.Builder()
.setShareHashtag(new ShareHashtag.Builder()
.setHashtag(getString(R.string.nomorehomelessanimals)).build())
.setQuote(getString(R.string.explore_adoption))
.setContentUrl(Uri.parse(getString(R.string.findmeahome_store_url)))
.build();
shareDialog.show(linkContent);
}
}
示例6: openFbDialog
import com.facebook.share.model.ShareLinkContent; //导入依赖的package包/类
public void openFbDialog(int v) {
boolean installed = appInstalledOrNot("com.facebook.katana");
if (installed) {
Bitmap image = getPersonalHeartRateBitmap(v);
SharePhoto photo = new SharePhoto.Builder()
.setBitmap(image)
.build();
SharePhotoContent photoContent = new SharePhotoContent.Builder()
.addPhoto(photo)
.build();
mShareDialog.show(photoContent);
} else {
ShareLinkContent linkContent = new ShareLinkContent.Builder()
.setContentTitle(String.format(mContext.getString(R.string.share_message_format), v))
.setContentDescription(
String.format(mContext.getString(R.string.share_message_format), v))
.setContentUrl(Uri.parse("https://play.google.com/store/apps/details?id=fr.machada.bpm"))
.build();
mShareDialog.show(linkContent);
}
}
示例7: onCreate
import com.facebook.share.model.ShareLinkContent; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
FacebookSdk.sdkInitialize(this.getApplicationContext());
callbackManager = CallbackManager.Factory.create();
shareDialog = new ShareDialog(this);
shareDialog.registerCallback(
callbackManager,
shareCallback);
// Can we present the share dialog for regular links?
canPresentShareDialog = ShareDialog.canShow(
ShareLinkContent.class);
// Can we present the share dialog for photos?
canPresentShareDialogWithPhotos = ShareDialog.canShow(
SharePhotoContent.class);
}
示例8: create
import com.facebook.share.model.ShareLinkContent; //导入依赖的package包/类
public static Bundle create(ShareLinkContent shareLinkContent) {
Bundle params = new Bundle();
Utility.putUri(
params,
ShareConstants.WEB_DIALOG_PARAM_HREF,
shareLinkContent.getContentUrl());
return params;
}
示例9: create
import com.facebook.share.model.ShareLinkContent; //导入依赖的package包/类
public static Bundle create(
UUID callId,
ShareContent shareContent,
boolean shouldFailOnDataError) {
Validate.notNull(shareContent, "shareContent");
Validate.notNull(callId, "callId");
Bundle nativeParams = null;
if (shareContent instanceof ShareLinkContent) {
final ShareLinkContent linkContent = (ShareLinkContent) shareContent;
nativeParams = create(linkContent, shouldFailOnDataError);
} else if (shareContent instanceof SharePhotoContent) {
final SharePhotoContent photoContent = (SharePhotoContent) shareContent;
List<String> photoUrls = ShareInternalUtility.getPhotoUrls(
photoContent,
callId);
nativeParams = create(photoContent, photoUrls, shouldFailOnDataError);
} else if (shareContent instanceof ShareVideoContent) {
final ShareVideoContent videoContent = (ShareVideoContent) shareContent;
String videoUrl = ShareInternalUtility.getVideoUrl(videoContent, callId);
nativeParams = create(videoContent, videoUrl, shouldFailOnDataError);
} else if (shareContent instanceof ShareOpenGraphContent) {
final ShareOpenGraphContent openGraphContent = (ShareOpenGraphContent) shareContent;
try {
JSONObject openGraphActionJSON = ShareInternalUtility.toJSONObjectForCall(
callId, openGraphContent);
openGraphActionJSON = ShareInternalUtility.removeNamespacesFromOGJsonObject(
openGraphActionJSON, false);
nativeParams = create(openGraphContent, openGraphActionJSON, shouldFailOnDataError);
} catch (final JSONException e) {
throw new FacebookException(
"Unable to create a JSON Object from the provided ShareOpenGraphContent: "
+ e.getMessage());
}
}
return nativeParams;
}
示例10: validateLinkContent
import com.facebook.share.model.ShareLinkContent; //导入依赖的package包/类
private static void validateLinkContent(
ShareLinkContent linkContent, Validator validator) {
Uri imageUrl = linkContent.getImageUrl();
if (imageUrl != null && !Utility.isWebUri(imageUrl)) {
throw new FacebookException("Image Url must be an http:// or https:// url");
}
}
示例11: create
import com.facebook.share.model.ShareLinkContent; //导入依赖的package包/类
public static Bundle create(
UUID callId,
ShareContent shareContent,
boolean shouldFailOnDataError) {
Validate.notNull(shareContent, "shareContent");
Validate.notNull(callId, "callId");
Bundle nativeParams = null;
if (shareContent instanceof ShareLinkContent) {
final ShareLinkContent linkContent = (ShareLinkContent)shareContent;
nativeParams = create(linkContent, shouldFailOnDataError);
} else if (shareContent instanceof SharePhotoContent) {
final SharePhotoContent photoContent = (SharePhotoContent)shareContent;
List<String> photoUrls = ShareInternalUtility.getPhotoUrls(
photoContent,
callId);
nativeParams = create(photoContent, photoUrls, shouldFailOnDataError);
} else if (shareContent instanceof ShareVideoContent) {
final ShareVideoContent videoContent = (ShareVideoContent)shareContent;
nativeParams = create(videoContent, shouldFailOnDataError);
} else if (shareContent instanceof ShareOpenGraphContent) {
final ShareOpenGraphContent openGraphContent = (ShareOpenGraphContent) shareContent;
try {
JSONObject openGraphActionJSON = ShareInternalUtility.toJSONObjectForCall(
callId, openGraphContent);
nativeParams = create(openGraphContent, openGraphActionJSON, shouldFailOnDataError);
} catch (final JSONException e) {
throw new FacebookException(
"Unable to create a JSON Object from the provided ShareOpenGraphContent: "
+ e.getMessage());
}
}
return nativeParams;
}
示例12: onCreateView
import com.facebook.share.model.ShareLinkContent; //导入依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
final View view = inflater.inflate(R.layout.fragment_routine_completed, container);
fbShare = (ShareButton) view.findViewById(R.id.fb_share);
tvMessage = (DCTextView) view.findViewById(R.id.tv_message);
tvCompleted = (DCTextView) view.findViewById(R.id.tv_completed);
ivTooth = (ImageView) view.findViewById(R.id.iv_tooth);
if (getArguments() != null) {
final Routine.Type routineType = (Routine.Type)getArguments().getSerializable(KEY_ROUTINE_TYPE);
if (routineType != null) {
AudibleMessage audibleMessage;
String shareLinkMessage;
switch (routineType) {
case MORNING:
shareLinkMessage = getString(R.string.fb_share_morning_routine_completed);
audibleMessage = AudibleMessage.MORNING_ROUTINE_END;
break;
default:
shareLinkMessage = getString(R.string.fb_share_evening_routine_completed);
audibleMessage = AudibleMessage.EVENING_ROUTINE_END;
break;
}
tvMessage.setText(audibleMessage.getMessage(getActivity()));
ShareLinkContent shareLinkContent = new ShareLinkContent.Builder()
.setContentUrl(Uri.parse(DCConstants.DENTACARE_GOOGLE_PLAY))
.setShareHashtag(new ShareHashtag.Builder()
.setHashtag("#dentacoin")
.build())
.setQuote(shareLinkMessage)
.build();
fbShare.setShareContent(shareLinkContent);
if (audibleMessage.getVoices() != null && audibleMessage.getVoices().length > 0) {
DCSoundManager.getInstance().playVoice(getActivity(), audibleMessage.getVoices()[0]);
}
}
}
AlphaAnimation alphaAnimation = new AlphaAnimation(0f, 1f);
alphaAnimation.setDuration(1000);
ivTooth.startAnimation(alphaAnimation);
AlphaAnimation dayAlphaAnimation = new AlphaAnimation(0f, 1f);
dayAlphaAnimation.setDuration(2000);
tvCompleted.startAnimation(dayAlphaAnimation);
AlphaAnimation alphaAnimationMessage = new AlphaAnimation(0f, 1f);
alphaAnimationMessage.setDuration(1000);
tvMessage.startAnimation(alphaAnimationMessage);
return view;
}
示例13: getView
import com.facebook.share.model.ShareLinkContent; //导入依赖的package包/类
@Override
public View getView(final int position, View convertView, ViewGroup parent) {
final ViewHolder holder;
if (convertView==null)
{
holder=new ViewHolder();
ShareLinkContent content = new ShareLinkContent.Builder()
.setContentUrl(Uri.parse(feeds.get(position).getImage_url()))
.build();
inflater=LayoutInflater.from(context);
convertView= inflater.inflate(R.layout.activity_feeds_list, parent, false);
holder.ivfeedimage= (ImageView) convertView.findViewById(R.id.iv_feed);
holder.tvtitle= (TextView) convertView.findViewById(R.id.tv_feed_title);
holder.tvmatter= (TextView) convertView.findViewById(R.id.tv_feed_matter);
holder.tvdate= (TextView) convertView.findViewById(R.id.tv_date);
convertView.setTag(holder);
}
else
{
holder= (ViewHolder) convertView.getTag();
}
try {
holder.tvtitle.setText(feeds.get(position).getTitle());
holder.tvtitle.setTypeface(typeface);
holder.tvtitle.setTextColor(R.color.com_facebook_button_background_color);
holder.tvmatter.setText(Html.fromHtml(feeds.get(position).getMatter()));
holder.tvdate.setText("Posted at :"+feeds.get(position).getDate());
Picasso.with(context).load(feeds.get(position).getImage_url()).fit().placeholder(R.drawable.placeholder).into( holder.ivfeedimage);
}
catch (Exception e){e.printStackTrace();}
return convertView;
}
示例14: shareLinkOnFacebook
import com.facebook.share.model.ShareLinkContent; //导入依赖的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();
}
}
示例15: shareFacebook
import com.facebook.share.model.ShareLinkContent; //导入依赖的package包/类
/**
* This method creates a facebook share button
*
* @param shareButton button pressed for a facebook share button
*/
public void shareFacebook(View shareButton) {
ShareLinkContent content = new ShareLinkContent.Builder()
.setContentUrl(Uri.parse(mUser.shareLinks.get("facebook")))
.setContentTitle("Get SaaS for 10% less!")
.setContentDescription("Sign up for a SaaS account and we both get 10% off our SaaS!")
.build();
ShareDialog dialog = new ShareDialog(this);
if (ShareDialog.canShow(ShareLinkContent.class)) {
dialog.show(content);
}
}