Demo entry 6644705

Example

   

Submitted by anonymous on Oct 06, 2017 at 03:15
Language: Java. Code size: 2.4 kB.

import android.support.multidex.MultiDexApplication; i
        Import android.util.Log; import com.amazonaws.auth.AWSCredentialsProvider;
        import com.amazonaws.mobile.config.AWSConfiguration;
        import com.amazonaws.mobile.auth.core.IdentityManager;
        import com.amazonaws.mobileconnectors.pinpoint.PinpointManager;
        import com.amazonaws.mobileconnectors.pinpoint.PinpointConfiguration;
        //. . .

        public class Application extends MultiDexApplication {
            private static final String LOG_TAG = Application.class.getSimpleName();
            public static PinpointManager pinpointManager;

        @Override public void onCreate() {
            super.onCreate();
            initializeApplication();

            // Application initialized
        }

        private void initializeApplication() {
            AWSConfiguration awsConfig = new AWSConfiguration(getApplicationContext());

            // If IdentityManager is not created, create it
            if (IdentityManager.getDefaultIdentityManager() == null) {
                AWSConfiguration awsConfiguration = new AWSConfiguration(
                    getApplicationContext());

            IdentityManager identityManager = new IdentityManager(
                getApplicationContext(), awsConfiguration);

            IdentityManager.setDefaultIdentityManager(identityManager); }

            // Register identity providers here.
            // If none are registered IdentityManager retrieves
            // unauthenticated AWS credentials.

            final AWSCredentialsProvider credentialsProvider =
                IdentityManager.getDefaultIdentityManager().getCredentialsProvider();

            PinpointConfiguration pinpointConfig =
                new PinpointConfiguration(
                    getApplicationContext(),
                    credentialsProvider,
                    awsConfig);

            Application.pinpointManager = new PinpointManager(pinpointConfig); pinpointManager.getSessionClient().startSession();

            // Choose a meaningful point in your apps lifecycle to mark the end of your session

            // pinpointManager.getSessionClient().stopSession();
            // pinpointConfigtManager.getAnalyticsClient().submitEvents();

        }

    }

This snippet took 0.01 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).