I'm assuming you have done all basic configuration like adding appid
in Strings.xml activity
declaration in AndroidManifest.xml
So all you need to do is activate the EventLogger
via Application
class.
public class MyApp extends Application {
private static AppEventsLogger mLogger;
@Override
public void onCreate() {
super.onCreate();
AppEventsLogger.activateApp(this);
}
public AppEventsLogger getAppLoggerInstance(){
if(mLogger == null){
return mLogger = AppEventsLogger.newLogger(this);
}
return mLogger;
}
}
And user your AppEventLogger
instance in Activity like this :
private void logFbEvent(String mEventName ){
AppEventsLogger mLogger = ((MyApp)getApplication()).getAppLoggerInstance();
mLogger.logEvent(mEventName);
}
PS :
Application
class has to be declared in AndroidManifest.xml
like this
<application
android:name=".QTConnectApp"
....