0

I'm trying to get an android app to log to facebook analytics, i've followed many different guides:

Android quickstart

quickstarts for a specific facebook app

Getting started

And checked that my key hashes are correct with these:

Generate debug key hash

Generate release key hash

How can i debug this? Do events from simulator show up in event debugging or do i have to release new versions to test this?

Maybe someone with experience could share what is most likely wrong?

TamRock
  • 1,490
  • 1
  • 11
  • 27

1 Answers1

0

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 AppEventLoggerinstance 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"
  ....
Nilesh Deokar
  • 2,975
  • 30
  • 53