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


Java ShareDialog类代码示例

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


ShareDialog类属于com.facebook.share.widget包,在下文中一共展示了ShareDialog类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: onCreate

import com.facebook.share.widget.ShareDialog; //导入依赖的package包/类
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.home_view);
    callbackManager  = CallbackManager.Factory.create();
    shareDialog = new ShareDialog(this);

    //타이틀바의 글자를 중앙으로 만들기위해서 CustomBar를 제작.
    this.getSupportActionBar().setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
    this.getSupportActionBar().setCustomView(R.layout.home_titlebar);

    //CardNews View
    cardNewsList = new ArrayList<CardNewsItem>();
    RecyclerView rv = (RecyclerView) findViewById(R.id.rv);

    rv.setHasFixedSize(true);

    //layoutManager
    RecyclerView.LayoutManager layoutManager = new LinearLayoutManager(getApplicationContext());
    rv.setLayoutManager(layoutManager);

    //카드 리스트뷰 어댑터에 연결
    adapter = new CardNewsAdapter(this, cardNewsList);
    rv.setAdapter(adapter);

    adapter.notifyDataSetChanged();

    Toast.makeText(getApplicationContext(), this.getIntent().getStringExtra("userName")+"님 환영합니다.",Toast.LENGTH_SHORT).show();

}
 
开发者ID:gugusny5758,项目名称:OSS-green-07,代码行数:30,代码来源:HomeActivity.java

示例6: 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

示例7: 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

示例8: 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

示例9: 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

示例10: shareOnFacebook

import com.facebook.share.widget.ShareDialog; //导入依赖的package包/类
private static void shareOnFacebook(){
    ShareLinkContent content = new ShareLinkContent.Builder()
            .setContentTitle(mMediaContent.getTitle())
            .setContentDescription(mMediaContent.getDescription())
            .setContentUrl(Uri.parse(mMediaContent.getImageSrc()))
            .build();

    ShareDialog.show(mActivity, content);
}
 
开发者ID:cscd-488,项目名称:event-app,代码行数:10,代码来源:ShareDrawer.java

示例11: ThanksShareViewHolder

import com.facebook.share.widget.ShareDialog; //导入依赖的package包/类
public ThanksShareViewHolder(final @NonNull View view) {
  super(view);
  this.viewModel = new ThanksShareHolderViewModel.ViewModel(environment());
  ButterKnife.bind(this, view);

  this.ksString = environment().ksString();
  this.shareDialog = new ShareDialog((Activity) context());

  this.viewModel.outputs.projectName()
    .compose(bindToLifecycle())
    .compose(observeForUI())
    .subscribe(this::showBackedProject);

  this.viewModel.outputs.startShare()
    .compose(bindToLifecycle())
    .compose(observeForUI())
    .subscribe(this::startShare);

  this.viewModel.outputs.startShareOnFacebook()
    .compose(bindToLifecycle())
    .compose(observeForUI())
    .subscribe(this::startShareOnFacebook);

  this.viewModel.outputs.startShareOnTwitter()
    .compose(bindToLifecycle())
    .compose(observeForUI())
    .subscribe(this::startShareOnTwitter);
}
 
开发者ID:kickstarter,项目名称:android-oss,代码行数:29,代码来源:ThanksShareViewHolder.java

示例12: share

import com.facebook.share.widget.ShareDialog; //导入依赖的package包/类
@OnClick(R.id.button_social)
public void share(final View view) {
    if (editing) {
        setTextAndHideKeyboard(view);
    } else {
        AlertDialog.Builder builder = new AlertDialog.Builder(context)
                .setTitle("Share with:")
                .setItems(MainActivity.SOCIAL_MEDIA_PLATFORMS, new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        switch (which) {
                            case 0:
                                makeSnackbar(view, "Selected " + MainActivity.SOCIAL_MEDIA_PLATFORMS[0]);
                                Bitmap crop = ((BitmapDrawable) imageView.getDrawable()).getBitmap();
                                Bitmap preview = ((BitmapDrawable) previewImage.getDrawable()).getBitmap();
                                SharePhoto cropPhoto = new SharePhoto.Builder()
                                        .setBitmap(crop)
                                        .build();
                                SharePhoto previewPhoto = new SharePhoto.Builder()
                                        .setBitmap(preview)
                                        .build();
                                ShareContent shareContent = new ShareMediaContent.Builder()
                                        .addMedium(cropPhoto)
                                        .addMedium(previewPhoto)
                                        .build();

                                ShareDialog shareDialog = new ShareDialog((Activity) context);
                                shareDialog.show(shareContent, ShareDialog.Mode.AUTOMATIC);
                                break;
                        }
                    }
                });
        builder.show();
    }
}
 
开发者ID:IgorGee,项目名称:Carbonizr,代码行数:36,代码来源:CustomAdapter.java

示例13: reciclo

import com.facebook.share.widget.ShareDialog; //导入依赖的package包/类
public static void reciclo(ShareDialog shareDialog){
    //TODO Get random phrases
    ShareLinkContent linkContent = new ShareLinkContent.Builder()
            .setContentTitle("Reciclô")
            .setContentDescription(
                    "Veja só o que acabei de fazer utilizando o Reciclô!")
            .setContentUrl(Uri.parse("http://developers.facebook.com/android"))
            .build();

    shareDialog.show(linkContent);
}
 
开发者ID:WilderPereira,项目名称:Reciclo,代码行数:12,代码来源:Utils.java

示例14: 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

示例15: 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


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