我找不到FB + Android SDK中的许多例子,样品是不够简单(其中有些是去precated)。我简单的目标是用我的Android应用程序共享FB上的一些内容。当我开发的iOS应用程序是简单
I cannot find many examples of the FB + Android SDK and the samples are not simple enough(some of them are deprecated). My simple goal is to share some content on FB using my Android app. When I developed the iOS app it was simply
AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
[appDelegate facebookLogin];
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
@"pikSpeak", @"name",
shareURL, @"link",
@"pikSpeak for iPhone !", @"caption",
@"Record audio at the moment of the image taken using pikSpeak and feel the moment come alive", @"description",
@"shared an audible pic using pikSpeak cam", @"message",
imageURL,@"picture",
nil];
[[appDelegate facebook] requestWithGraphPath:@"feed" andParams:params andHttpMethod:@"POST" andDelegate:self];
这code处理的会话并保存会话信息在应用程序重新启动。
This code handled the sessions and saving the session details over app restarts.
1)如何简单地分享一些东西的Android。
1) How to simply share some thing in Android.
2)我看到的Facebook(字符串APP_ID)
是德precated。如果是这样,那么什么是它的替代?
2) I saw Facebook(String app_id)
is deprecated. If so, then what is its replacement?
P.S。 :使用Facebook 3.0 SDK
P.S. : Using Facebook 3.0 SDK
从的分享到用户的墙使用Facebook的SDK :
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", "https://m.xsw88.com/allimgs/daicuo/20230905/456.png");
new WebDialog.FeedDialogBuilder(mContext, mySession, bundle).build().show();
}
如果您需要登录(在你的活动,无论你需要登录/股添加此):
If you need to login (add this in you activity wherever you need to login/share):
Session.openActiveSession(this, true, new Session.StatusCallback() {
@Override
public void call(Session session, SessionState state, Exception exception) {
if(session.isOpened()) {
share();
}
}
});
您将需要添加到您的活动:
You will need to add to your activity:
@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;
}
}