Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
955 views
in Technique[技术] by (71.8m points)

android - FacebookSdk.sdkInitialize (Context) is deprecated

I'm using facebook-android-sdk-4.19.0 in Android Studio and I followed the Facebook quick start guide at https://developers.facebook.com/docs/android/getting-started (Click on the Quick Start button to sign in with your own facebook account). In the guide, it's told to copy&paste the following code in the snippet to track app logs

import com.facebook.FacebookSdk;
import com.facebook.appevents.AppEventsLogger;

public class MyApplication extends Application {
    @Override
    public void onCreate() {
        super.onCreate();
        FacebookSdk.sdkInitialize(getApplicationContext());
        AppEventsLogger.activateApp(this);
    }
}

However, when I copy pasted the code in android studio, it appears that all of the FacebookSdk.sdkInitialize() methods are deprecated. The documentation here https://developers.facebook.com/docs/reference/android/current/class/FacebookSdk/ tells nothing about what method to use to initialize the sdk instead of sdkInitialize(). What method should I use?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

From the documentation about upgrading SDK:

The Facebook SDK is now auto initialized on Application start. If you are using the Facebook SDK in the main process and don't need a callback on SDK initialization completion you can now remove calls to FacebookSDK.sdkInitialize. If you do need a callback, you should manually invoke the callback in your code.

Refer to: https://developers.facebook.com/docs/android/upgrading-4x

UPDATE

In SDK 4.22 the title, description, caption and image field of FBSDKShareLinkContent are deprecated. Consider removing them from usage.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...