当前位置: 首页>>代码示例>>Java>>正文


Java ShareDialog.canShow方法代码示例

本文整理汇总了Java中com.facebook.share.widget.ShareDialog.canShow方法的典型用法代码示例。如果您正苦于以下问题:Java ShareDialog.canShow方法的具体用法?Java ShareDialog.canShow怎么用?Java ShareDialog.canShow使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.facebook.share.widget.ShareDialog的用法示例。


在下文中一共展示了ShareDialog.canShow方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: compartir

import com.facebook.share.widget.ShareDialog; //导入方法依赖的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);
    }
}
 
开发者ID:pedroag,项目名称:TFG,代码行数:25,代码来源:PantallaVictoria.java

示例2: startShareOnFacebook

import com.facebook.share.widget.ShareDialog; //导入方法依赖的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);
}
 
开发者ID:kickstarter,项目名称:android-oss,代码行数:27,代码来源:ThanksShareViewHolder.java

示例3: shareOnFacebook

import com.facebook.share.widget.ShareDialog; //导入方法依赖的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);
        }
    }
 
开发者ID:juanjecilla,项目名称:FindMeAHome,代码行数:17,代码来源:ListActivity.java

示例4: onCreate

import com.facebook.share.widget.ShareDialog; //导入方法依赖的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);
}
 
开发者ID:JimRoid,项目名称:EasyFacebook,代码行数:19,代码来源:BaseLoginActivity.java

示例5: shareImage

import com.facebook.share.widget.ShareDialog; //导入方法依赖的package包/类
public void shareImage(ArrayList<String> cards){
    try {
        List<SharePhoto> convertCards = new ArrayList<SharePhoto>();
        SharePhoto photo;

        for (int i = 0; i < cards.size(); i++) {
            Uri uri = Uri.fromFile(new File(cards.get(i)));
            Bitmap bitmap = MediaStore.Images.Media.getBitmap(this.getContentResolver(), uri);
            int nh = (int) (bitmap.getHeight() * (1024.0 / bitmap.getWidth()));
            Bitmap scaled = Bitmap.createScaledBitmap(bitmap, 1024, nh, true);

            photo = new SharePhoto.Builder()
                    .setBitmap(scaled)
                    .build();
            convertCards.add(photo);
        }

        ShareContent content  = new SharePhotoContent.Builder().addPhotos(convertCards).build();

        if(ShareDialog.canShow(SharePhotoContent.class)){
            shareDialog.show(content);
        }

    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
开发者ID:gugusny5758,项目名称:OSS-green-07,代码行数:28,代码来源:HomeActivity.java

示例6: shareLinkOnFacebook

import com.facebook.share.widget.ShareDialog; //导入方法依赖的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

示例7: shareFacebook

import com.facebook.share.widget.ShareDialog; //导入方法依赖的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);
    }
}
 
开发者ID:saasquatch,项目名称:mobile-sdk-android-sample,代码行数:19,代码来源:WelcomeActivity.java

示例8: setUpShareConfig

import com.facebook.share.widget.ShareDialog; //导入方法依赖的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

示例9: shareLink

import com.facebook.share.widget.ShareDialog; //导入方法依赖的package包/类
/**
 * Share ritch content on facebook.
 * @param activity              Application base context.
 * @param contentUrl            Redirect url.
 * @param contentTitle          Title of content.
 * @param imageUrl              url of content's image.
 * @param contentDescription    description of the content.
 */
public void shareLink(Activity activity, String contentUrl, String contentTitle, String imageUrl, String contentDescription) {
    ShareDialog shareDialog = new ShareDialog(activity);

    if (ShareDialog.canShow(ShareLinkContent.class)) {
        ShareLinkContent content = new ShareLinkContent.Builder()
                .setContentUrl(Uri.parse(contentUrl))
                .setContentTitle(contentTitle)
                .setContentDescription(contentDescription)
                .setImageUrl(Uri.parse(imageUrl)).build();

        shareDialog.show(content);
    }

}
 
开发者ID:kgeriiie,项目名称:android-fagyi,代码行数:23,代码来源:FacebookHandler.java

示例10: sharePhoto

import com.facebook.share.widget.ShareDialog; //导入方法依赖的package包/类
/**
 * share bitmap content.
 * @param bitmap
 */
public void sharePhoto(Bitmap bitmap) {

    SharePhoto photo = new SharePhoto.Builder()
            .setBitmap(bitmap)
            .build();

    SharePhotoContent photoContent = new SharePhotoContent.Builder().addPhoto(photo).build();

    ShareDialog shareDialog = new ShareDialog(activity);

    if (ShareDialog.canShow(SharePhotoContent.class)) {
        shareDialog.show(photoContent);
    }
}
 
开发者ID:kgeriiie,项目名称:android-fagyi,代码行数:19,代码来源:FacebookHandler.java

示例11: onShareResult

import com.facebook.share.widget.ShareDialog; //导入方法依赖的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

示例12: shareToFacebook

import com.facebook.share.widget.ShareDialog; //导入方法依赖的package包/类
private void shareToFacebook() {
    if (ShareDialog.canShow(ShareLinkContent.class)) {
        ShareLinkContent linkContent = new ShareLinkContent.Builder()
                .setContentTitle(mGoodThing.getTitle())
                .setContentUrl(Uri.parse(getGoogleMapUri()))
                .setImageUrl(Uri.parse(mGoodThing.getImageUrl()))
                .setContentDescription(mGoodThing.getMemo() + "   " + mGoodThing.getStory())
                .build();
        shareDialog.show(linkContent);
    }else {
        shareToAppNotFound("com.facebook.katana", "Facebook");
        return;
    }
}
 
开发者ID:bearprada,项目名称:good-thing-map-android,代码行数:15,代码来源:DetailActivity.java


注:本文中的com.facebook.share.widget.ShareDialog.canShow方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。