gpt4 book ai didi

android - Facebook 对话教程 - 是否缺少某些内容?

转载 作者:行者123 更新时间:2023-11-29 01:49:51 24 4
gpt4 key购买 nike

这是来自以下页面的代码: https://developers.facebook.com/docs/android/share-dialog/#setup

我试图让它工作,但在实例化 UILifecycleHelper 类时,我对“回调”参数感到非常困惑。 (查看教程代码)我看不到这个变量来自哪里。我试图创建一个 null 对象并传递它,但(出乎意料)得到了一个 NullPointerException。

Facebook 是否在这里忘记了一步,或者是否有一些隐含的知识让我对回调的不理解又回来困扰我?

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

uiHelper = new UiLifecycleHelper(this, callback); // line 45 in code
uiHelper.onCreate(savedInstanceState);
}

谢谢你的帮助

//编辑(再次)- 错误痕迹

这是堆栈跟踪 - 还有很多 ECLIPSE 错误需要处理(不知道如何摆脱它们),所以忽略这些错误:

09-16 19:24:20.533: E/AndroidRuntime(1348): FATAL EXCEPTION: main
09-16 19:24:20.533: E/AndroidRuntime(1348): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.theperspectableone.carddisplayertemplate/com.theperspectableone.carddisplayertemplate.MainActivity}: java.lang.NullPointerException: Argument 'applicationId' cannot be null
09-16 19:24:20.533: E/AndroidRuntime(1348): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2211)
09-16 19:24:20.533: E/AndroidRuntime(1348): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261)
09-16 19:24:20.533: E/AndroidRuntime(1348): at android.app.ActivityThread.access$600(ActivityThread.java:141)
09-16 19:24:20.533: E/AndroidRuntime(1348): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
09-16 19:24:20.533: E/AndroidRuntime(1348): at android.os.Handler.dispatchMessage(Handler.java:99)
09-16 19:24:20.533: E/AndroidRuntime(1348): at android.os.Looper.loop(Looper.java:137)
09-16 19:24:20.533: E/AndroidRuntime(1348): at android.app.ActivityThread.main(ActivityThread.java:5103)
09-16 19:24:20.533: E/AndroidRuntime(1348): at java.lang.reflect.Method.invokeNative(Native Method)
09-16 19:24:20.533: E/AndroidRuntime(1348): at java.lang.reflect.Method.invoke(Method.java:525)
09-16 19:24:20.533: E/AndroidRuntime(1348): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
09-16 19:24:20.533: E/AndroidRuntime(1348): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
09-16 19:24:20.533: E/AndroidRuntime(1348): at dalvik.system.NativeStart.main(Native Method)
09-16 19:24:20.533: E/AndroidRuntime(1348): Caused by: java.lang.NullPointerException: Argument 'applicationId' cannot be null
09-16 19:24:20.533: E/AndroidRuntime(1348): at com.facebook.internal.Validate.notNull(Validate.java:29)
09-16 19:24:20.533: E/AndroidRuntime(1348): at com.facebook.Session.<init>(Session.java:227)
09-16 19:24:20.533: E/AndroidRuntime(1348): at com.facebook.Session.<init>(Session.java:212)
09-16 19:24:20.533: E/AndroidRuntime(1348): at com.facebook.UiLifecycleHelper.onCreate(UiLifecycleHelper.java:87)
09-16 19:24:20.533: E/AndroidRuntime(1348): at com.theperspectableone.carddisplayertemplate.MainActivity.onCreate(MainActivity.java:45)
09-16 19:24:20.533: E/AndroidRuntime(1348): at android.app.Activity.performCreate(Activity.java:5133)
09-16 19:24:20.533: E/AndroidRuntime(1348): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
09-16 19:24:20.533: E/AndroidRuntime(1348): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2175)
09-16 19:24:20.533: E/AndroidRuntime(1348): ... 11 more

最佳答案

答案与 Idipaolo 所说的相同....您必须按照设置说明和共享对话框进行操作。

您最终需要使用 Facebook 创建一个开发者帐户,这还需要满足以下条件:

Having "keytool" in your computer ENVIRONMENT VARIABLES
Installing and having "openssl" in your computer ENVIRONMENT VARIABLES
Creating a keystore
Creating a Key
Creating a new App on the Facebook Developer page
Putting the Key in the app info page
Getting an App ID from Facebook
A plethora of other setup things in your Android file

这个站点帮助我获得了 key (尽管实际的 FB 代码已被弃用):http://www.androidhive.info/2012/03/android-facebook-connect-tutorial/

这让对话框启动并运行(尽管有一行已被弃用,但仍然让我感到悲伤*):https://developers.facebook.com/docs/android/share-dialog/#setup

*Request.executeMeRequestAsync(session, new Request.GraphUserCallback() {

关于android - Facebook 对话教程 - 是否缺少某些内容?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18838656/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com