这是来自以下页面的代码: https ://developers.facebook.com/docs/android/share-dialog/#setup
我试图让它工作,但在实例化 UILifecycleHelper 类时对“回调”参数感到非常困惑。(查看教程代码)我看不出这个变量是从哪里来的。我试图创建一个空对象并传递它,但(惊喜)得到了 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