不推荐使用FacebookSdk.sdkInitialize(Context) [英] FacebookSdk.sdkInitialize (Context) is deprecated

查看:638
本文介绍了不推荐使用FacebookSdk.sdkInitialize(Context)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Android Studio中使用了facebook-android-sdk-4.19.0,并按照 https://developers.facebook.com/docs/android/getting-started (点击快速开始按钮,用你自己的facebook账户登录)。在指南中,它被要求在代码段中复制并粘贴以下代码以跟踪应用程序日志

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);
    }
}

但是,当我复制粘贴在android工作室的代码,似乎所有的FacebookSdk.sdkInitialize()方法已被弃用。这里的文档是 https://developers.facebook.com/docs/reference/android/current/ class / FacebookSdk / 什么也不介绍使用什么方法来初始化sdk而不是sdkInitialize()。我应该使用什么方法?

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?

推荐答案

从有关升级SDK的文档:

From the documentation about upgrading SDK:


Facebook SDK现在在应用程序启动时自动初始化。如果
在主程序中使用Facebook SDK,并且在SDK初始化完成时不需要
回调,您现在可以删除对
FacebookSDK.sdkInitialize的调用。如果你需要一个回调,你应该
手动调用代码中的回调。

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.

参考: https://developers.facebook.com/docs/android/upgrading-4x

更新

在SDK 4.22中标题描述 caption image FBSDKShareLinkContent 已被弃用。考虑将其从使用中删除。

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

这篇关于不推荐使用FacebookSdk.sdkInitialize(Context)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆