Login with Facebook using Facebook SDK 3.0

Now I need to click on the button and this button to activate the login with the facebook notification.

Now, so far, I have been using old code that works but is deprecated, so I need to use a new one that I cannot understand. Where does he use the string APP_ID? Now I have taken HelloFacebookSample and SessionLoginSample, but they both fail when I try to run them on my phone. Then I tried this code: https://developers.facebook.com/docs/howtos/androidsdk/3.0/login-with-facebook/ But it does the same.

Here is what logcat says:

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) 

Can someone please help me with a working tutorial / example?

Now I also tried this code: https://github.com/fbsamples/android-3.0-howtos/blob/master/LoginHowTo/src/com/facebook/samples/loginhowto/MainFragment.java

but still i get the same error. Now I looked at logcat and worked, because application_id is null (in sdk code). Now they instantiate using UIhelper. but when I create uihelper (UiLifecycleHelper), I have no way to pass APP_ID to it, why? should I be able to pass application_id someherE?

+4
source share
1 answer

I need to specify the application identifier in the manifest as follows:

 <meta-data android:name="com.facebook.sdk.ApplicationId" android:value="@string/app_id"/> 

I have this code: https://github.com/fbsamples/android-3.0-howtos/tree/master/LoginHowTo but the only difference is that I need to have activity without fragment, so I changed authButton.setFragment(this); with authButton.setSessionStatusCallback(callback); Now the only problem is that after logging in with the dialog box, it does not enter my onSessionStateChange .

+14
source

Source: https://habr.com/ru/post/1468970/


All Articles