取自使用 Facebook SDK 在用户墙上分享 http://www.sherif.mobi/2013/04/share-on-users-wall-using-facebook-sdk.html:
private void share() {
Bundle bundle = new Bundle();
bundle.putString("caption", "Harlem Shake Launcher for Android");
bundle.putString("description", "Your android can do the Harlem Shake. Download it from google play");
bundle.putString("link", "https://play.google.com/store/apps/details?id=mobi.shush.harlemlauncher");
bundle.putString("name", "Harlem Shake Launcher");
bundle.putString("picture", "http://shush.mobi/bla.png");
new WebDialog.FeedDialogBuilder(mContext, mySession, bundle).build().show();
}
如果您需要登录(在您需要登录/共享的任何地方添加此活动):
Session.openActiveSession(this, true, new Session.StatusCallback() {
@Override
public void call(Session session, SessionState state, Exception exception) {
if(session.isOpened()) {
share();
}
}
});
您需要添加到您的活动中:
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
switch(requestCode) {
default:
if(Session.getActiveSession() != null) //I need to check if this null just to sleep peacefully at night
Session.getActiveSession().onActivityResult(this, requestCode, resultCode, data);
break;
}
}