码迷,mamicode.com
首页 > 其他好文 > 详细

【FacebookSDK学习笔记】Facebook消息分享

时间:2015-03-04 19:12:00      阅读:2971      评论:0      收藏:0      [点我收藏+]

标签:facebook   sdk   

1.手机上要安装了Facebook Message才能使用这个功能

Google Play网址:https://play.google.com/store/apps/details?id=com.facebook.orca


2.直接添加一个button

 <Button
    android:id="@+id/messageButton"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:textStyle="bold"
    android:gravity="center"
    android:layout_marginTop="30dp"
    android:visibility="invisible"
    android:text="message"
   />

3.添加监听事件即可

FacebookDialog.MessageDialogBuilder builder = new FacebookDialog.MessageDialogBuilder(getActivity())
		    .setLink("https://developers.facebook.com/docs/android/share/")
		    .setName("Message Dialog Tutorial")
		    .setCaption("Build great social apps that engage your friends.")
		    .setPicture("http://i.imgur.com/g3Qc1HN.png")
		    .setDescription("Allow your users to message links from your app using the Android SDK.")
		    .setFragment(this);

		// If the Facebook app is installed and we can present the share dialog
		if (builder.canPresent()) {
		  // Enable button or other UI to initiate launch of the Message Dialog
			FacebookDialog dialog = builder.build();
			dialog.present();
		}  else {
		  // Disable button or other UI for Message Dialog 
			Log.e("===Error===","Error!No Message!");//出现此log说明未安装Messager
		}

技术分享

如下图:

技术分享

效果图::

技术分享

【FacebookSDK学习笔记】Facebook消息分享

标签:facebook   sdk   

原文地址:http://blog.csdn.net/lovekam/article/details/44062839

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!