/** * 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); } }
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); }
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); } }
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) { } }); }
@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); }
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(); }
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(); } }
/** * 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(); } }
/** * Handle Facebook */ public static void shareImageOnFace(Activity activity, RelativeLayout photoContent, View v) { // Cria conteudo para ser publicado no face SharePhoto photo = new SharePhoto.Builder().setBitmap(ImageUtil.drawBitmap(photoContent)).build(); SharePhotoContent content = new SharePhotoContent.Builder() .addPhoto(photo) .setShareHashtag(new ShareHashtag.Builder().setHashtag(HASHTAG).build()) .build(); new ShareDialog(activity).show(content); }
/** * 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); } }
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); } }
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); }
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); }
@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(); } }
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); }
/** * 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); } }
/** * 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); } }
@Override public void presentChannelInterface(InviteChannel inviteChannel, InvitePackage invitePackage, final InviteCallback callback) { if (isConnected()) { ShareLinkContent.Builder shareLinkBuilder = new ShareLinkContent.Builder(); shareLinkBuilder.setContentUrl(Uri.parse(invitePackage.getReferralUrl())); ShareLinkContent sharedContent = shareLinkBuilder.build(); ShareDialog shareDialog = new ShareDialog(_activity); shareDialog.registerCallback(_callbackManager, new FacebookCallback<ShareDialog.Result>() { @Override public void onSuccess(ShareDialog.Result result) { callback.onComplete(); } @Override public void onCancel() { callback.onCancel(); } @Override public void onError(FacebookException facebookException) { callback.onError(facebookException); } } ); shareDialog.show(sharedContent, ShareDialog.Mode.WEB); } else { onError("Can't reach Facebook. No internet connection.", callback); } }
@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; }
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(); }
/** * 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); }
public static void shareFacebook(Activity activity, String url, String imgUrl) { ShareLinkContent content = new ShareLinkContent.Builder() .setContentUrl(Uri.parse(url)) .setContentDescription(url) .setContentTitle("Wio") // .setImageUrl(imgUri) .build(); ShareDialog.show(activity, content); }
@Override public void onCreate(Bundle savedStateInstance) { super.onCreate(savedStateInstance); mGoodThing = getArguments().getParcelable(GoodThing.EXTRA_GOODTHING); mLocation = getArguments().getParcelable(GoodListActivity.EXTRA_LOCATION); mInflater = LayoutInflater.from(getActivity()); // Initialize Facebook sdk and ShareDialog FacebookSdk.sdkInitialize(getContext()); shareDialog = new ShareDialog(this); }
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; } }
@Override public void share(final String url, Fragment fragment) { ShareDialog shareDialog = new ShareDialog(fragment); setUpShareConfig(url, shareDialog); }
@Override public void share(String msg, Activity activity) { ShareDialog shareDialog = new ShareDialog(activity); setUpShareConfig(msg, shareDialog); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_recipe); toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setDisplayShowHomeEnabled(true); mDatabase = FirebaseUtils.getDatabase().getReference(); Bundle extras = getIntent().getExtras(); Recipe recipe = (Recipe) extras.getSerializable(getString(R.string.recipe_extra_key)); itemName = (TextView) findViewById(R.id.tv_item); favoriteCount = (TextView) findViewById(R.id.tv_favorite_count); recyleCount = (TextView) findViewById(R.id.tv_recycled_count); linearIngredients = (LinearLayout) findViewById(R.id.linear_ingredients); linearPreparation = (LinearLayout) findViewById(R.id.linear_preparation); btnReciclo = (Button) findViewById(R.id.btn_reciclo); itemImage = (SimpleDraweeView) findViewById(R.id.iv_recipe_image); itemName.setText(recipe.getName()); favoriteCount.setText(recipe.getFavoriteCount()+""); recyleCount.setText(recipe.getRecycleCount()+""); Uri uri = Uri.parse(recipe.getImgUrl()); itemImage.setImageURI(uri); getSupportActionBar().setTitle(""); recipe.getMissingItems(); String preparationId = recipe.getPreparation(); getPreparation(preparationId); String resourceId = recipe.getResource(); getResources(resourceId); FacebookSdk.sdkInitialize(getApplicationContext()); //CallbackManager callbackManager = CallbackManager.Factory.create(); shareDialog = new ShareDialog(this); }
@Override public ShareDialog getShareDialog() { return shareDialog; }
ShareDialog getShareDialog();