Is it possible to access onCreate method of Application class?

Hi,

I’m building an extension to log events with Facebook Analytics.
According to the documentation, we need to call some methods when the app is created:

package com.example.hellofacebook;

import android.app.Application;

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

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

Is there a way to achieve the same in an extension?

I’ve tried this in my extension:

@SimpleFunction(description = "Initialize SDK")
    public void Initialize(String facebookAppId) {
        FacebookSdk.setApplicationId(facebookAppId);
        FacebookSdk.sdkInitialize(this.container.$context().getApplicationContext());
        AppEventsLogger.activateApp(this.container.$context().getApplication());
        this.logger = AppEventsLogger.newLogger(this.container.$context());
    }

I call it the Initialize block of the screen I want to log events but it doesn’t seem to work. I got this warning in logcat: “W/com.facebook.appevents.internal.ActivityLifecycleTracker: Unexpected activity pause without a matching activity resume. Logging data may be incorrect. Make sure you call activateApp from your Application’s onCreate method”

Thank you for your help!

There should be a OncreateListener at the App Inventor sources.
EDIT:

Looks like there is only a OnCreateOptionsMenuListener listener…

You should open a issue at her github page with your request.

Thank you for your quick reply.

I was not aware of this listener.
I’ve opened an issue.

Thanks