1,项目级别的gradle:
buildscript {
repositories {
...
mavenCentral()
...
}
}
2,app级别的gradle:
implementation 'com.facebook.android:facebook-android-sdk:[5,6)'
3,清单文件
<meta-data android:name="com.facebook.sdk.ApplicationId" android:value="@string/facebook_app_id" />
<activity android:name="com.facebook.FacebookActivity" android:configChanges="keyboard|keyboardHidden|screenLayout|screenSize|orientation" android:label="@string/app_name" />
<uses-permission android:name="android.permission.INTERNET" />
4,初始化
application 的onCreate()方法里面
AppEventsLogger.activateApp(this)
5,统计方式
方式1:
AppEventsLogger logger = AppEventsLogger.newLogger(Context context);
logger.logEvent("自定义事件名称" );
方式2:
AppEventsLogger logger = AppEventsLogger.newLogger(Context context);
logger.logEvent("自定义事件名称" , int数值 );
方式3:
AppEventsLogger logger = AppEventsLogger.newLogger(this);
Bundle bundle = new Bundle();
bundle.putString("自定义key" , "自定义value");
bundle.putString("自定义key" , "自定义value");
logger.logEvent("自定义事件名称t" , 1 , bundle);