0

我需要一些建议来解决这个问题...我使用 facebook android sdk 从我的应用程序创建与 facebook 的集成...我遵循了本教程: http: //www.integratingstuff.com/2010/10/14/integrating -facebook-into-an-android-application/

我需要在一个活动中实现身份验证,在另一个活动中实现功能 postToWall ......在身份验证后,我想通过按下按钮发送帖子,但在其他活动中,与我进行身份验证的活动不同。

可能吗?还是使用 SDK 我被迫在同一个活动中一起做所有事情?

提前致谢

4

3 回答 3

0

您需要安装一个扩展,类似于核心 Android SDK,但不,这是您需要做的:

1.) 访问 github.com/facebook/facebook-android-sdk

2.) 只下载 facebook 目录!其他目录只是示例。

3.) 将 src 中的文件(如果需要,您也可以复制可绘制对象)放入您当前正在使用的包中

4.) 你很好,你可以使用 facebook "SDK"

另请参阅此示例https://github.com/facebook/facebook-android-sdk/tree/master/examples/Hackbook下载它,它是 facebook 提供的工作示例

于 2012-04-29T17:38:29.970 回答
0

对的,这是可能的。您将获得一个访问令牌,您可以将其发送到下一个活动。使用 getAccessToken() 和 setAccessToken()。

这是一个甚至保存所需数据的示例:Contact-Picture-Sync

于 2012-04-29T17:27:52.767 回答
0

just to provide an alternative answer, there's other ways of implementing sharing on Android.

It allows for more sharing options (like Twitter, QR-Barcodes, blogging and whatnot) without having to deal with the facebook android sdk.

What you would use is a "share" intent, like so:

String title = "My thing"; // used if you share through email or channels that require a headline for the content, always include this or some apps might not parse the content right

String wallPost = "Hey - check out this stuff: http://link.com "; // the content of your wallpost

String shareVia = "Share this stuff via"; // the headline for your chooser, where the phones avaliable sharing mechanisms are offered. 

Intent shareIntent = new Intent(android.content.Intent.ACTION_SEND);
            shareIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            shareIntent.setType("text/plain");


shareIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, title);

shareIntent.putExtra(android.content.Intent.EXTRA_TEXT, wallPost);

startActivity(Intent.createChooser(shareIntent, shareVia));

This is by far the preferred solution on Android if you're looking for simple sharing, as it makes your app future-compatible with new services. And more lean and flexible for the user too, as there's little to no friction from hitting the share button to posting content.

It can also be seen in this blog post: http://android-developers.blogspot.com/2012/02/share-with-intents.html

I hope you can use this for your project.

于 2012-04-29T18:04:38.760 回答