在 Facebook 上分享一些东西需要实现 FacebookSdk 3.0,请遵循本教程:
http ://www.kpbird.com/2013/03/android-login-using-facebook-sdk-30.html
主要目标是通过 facebook 提供“登录”以在墙上分享内容。登录成功后,请尝试以下方法:
private void publishStory(String hash, String title, String user) {
Session session = Session.getActiveSession();
if (session != null){
// Check for publish permissions
List<String> permissions = session.getPermissions();
if (!isSubsetOf(PERMISSIONS, permissions)) {
pendingPublishReauthorization = true;
Session.NewPermissionsRequest newPermissionsRequest = new Session
.NewPermissionsRequest(getActivity(), PERMISSIONS);
session.requestNewPublishPermissions(newPermissionsRequest);
return;
}
Bundle postParams = new Bundle();
postParams.putString("name", title);
postParams.putString("caption", "By Recommend Android");
postParams.putString("description", user+" "+"STRONGLY recommends"+" "+title);
postParams.putString("link", "http://re.co/"+hash);
postParams.putString("picture", "http://re.co/assets/img/useful-exp.png");
Request.Callback callback= new Request.Callback() {
public void onCompleted(Response response) {
JSONObject graphResponse = response
.getGraphObject()
.getInnerJSONObject();
String postId = null;
try {
postId = graphResponse.getString("id");
} catch (JSONException e) {
Log.i(TAG,
"JSON error "+ e.getMessage());
}
不要忘记您的 Html 标签必须在您的 strings.xml 中声明,如下所示:
<string name="demoStr"><Data><![CDATA[ <b>ABC</b><br /> something ]]> </Data></string>
然后 getString() 将得到"<b>ABC</b><br />something"