现在,我需要单击一个按钮,然后单击该按钮以使用 facebook 警报激活登录。
现在,直到现在,我一直使用旧代码,它可以工作,但已被弃用,所以我需要使用我无法理解的新代码。它在哪里使用 APP_ID 字符串?现在我使用了 HelloFacebookSample 和 SessionLoginSample,但是当我尝试在手机上运行它们时它们都崩溃了。然后我尝试了这段代码: https ://developers.facebook.com/docs/howtos/androidsdk/3.0/login-with-facebook/ 但它也是一样的。
这就是 logcat 所说的:
03-13 14:55:46.497: E/AndroidRuntime(28849): java.lang.RuntimeException: Unable to start activity ComponentInfo{ro.koolnet.android/ro.koolnet.android.ui.activities.LoginActivity}: java.lang.NullPointerException: Argument applicationId cannot be null
03-13 14:55:46.497: E/AndroidRuntime(28849): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2190)
03-13 14:55:46.497: E/AndroidRuntime(28849): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2215)
03-13 14:55:46.497: E/AndroidRuntime(28849): at android.app.ActivityThread.access$600(ActivityThread.java:145)
03-13 14:55:46.497: E/AndroidRuntime(28849): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1211)
03-13 14:55:46.497: E/AndroidRuntime(28849): at android.os.Handler.dispatchMessage(Handler.java:99)
03-13 14:55:46.497: E/AndroidRuntime(28849): at android.os.Looper.loop(Looper.java:137)
03-13 14:55:46.497: E/AndroidRuntime(28849): at android.app.ActivityThread.main(ActivityThread.java:4978)
03-13 14:55:46.497: E/AndroidRuntime(28849): at java.lang.reflect.Method.invokeNative(Native Method)
03-13 14:55:46.497: E/AndroidRuntime(28849): at java.lang.reflect.Method.invoke(Method.java:511)
03-13 14:55:46.497: E/AndroidRuntime(28849): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:791)
03-13 14:55:46.497: E/AndroidRuntime(28849): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:558)
03-13 14:55:46.497: E/AndroidRuntime(28849): at dalvik.system.NativeStart.main(Native Method)
03-13 14:55:46.497: E/AndroidRuntime(28849): Caused by: java.lang.NullPointerException: Argument applicationId cannot be null
03-13 14:55:46.497: E/AndroidRuntime(28849): at com.facebook.internal.Validate.notNull(Validate.java:29)
03-13 14:55:46.497: E/AndroidRuntime(28849): at com.facebook.Session.<init>(Session.java:224)
03-13 14:55:46.497: E/AndroidRuntime(28849): at com.facebook.Session.<init>(Session.java:209)
03-13 14:55:46.497: E/AndroidRuntime(28849): at com.facebook.UiLifecycleHelper.onCreate(UiLifecycleHelper.java:73)
有人可以帮我提供一个工作教程/示例吗?
但我仍然得到同样的错误。现在,我查看了 logcat,它崩溃了,因为 application_id 为空(在 sdk 代码中)。现在他们通过使用 UIhelper 来实例化它。但是当我创建 uihelper (UiLifecycleHelper) 时,我没有将 APP_ID 传递给它的选项,为什么?我应该有可能在某个地方传递 application_id 吗?