예제 #1
0
  /**
   * This method should be invoked when each activity is paused. It is used to assist in tracking
   * user session data in Amazon Mobile Analytics system.
   */
  public void handleOnPause() {

    SessionClient sessionClient = null;
    EventClient eventClient = null;

    try {
      if (mobileAnalyticsManager != null
          && (sessionClient = mobileAnalyticsManager.getSessionClient()) != null
          && (eventClient = mobileAnalyticsManager.getEventClient()) != null) {
        sessionClient.pauseSession();
        eventClient.submitEvents();
      }
    } catch (final Exception e) {
      Log.w(LOG_TAG, "Unable to report analytics. " + e.getMessage(), e);
    }
  }
예제 #2
0
  /**
   * This method should be called whenever any activity resumes. It assists in tracking user session
   * data in the Amazon Mobile Analytics system.
   */
  public void handleOnResume() {
    SessionClient sessionClient = null;

    try {
      if (mobileAnalyticsManager != null
          && (sessionClient = mobileAnalyticsManager.getSessionClient()) != null) {
        sessionClient.resumeSession();
      }
    } catch (final Exception e) {
      Log.w(LOG_TAG, "Unable to resume analytics. " + e.getMessage(), e);
    }
  }
예제 #3
0
  private AWSMobileClient(
      final Context context,
      final String cognitoIdentityPoolID,
      final Regions cognitoRegion,
      final String mobileAnalyticsAppID,
      final IdentityManager identityManager,
      final ClientConfiguration clientConfiguration) {

    this.context = context;
    this.identityManager = identityManager;
    this.clientConfiguration = clientConfiguration;

    try {
      this.mobileAnalyticsManager =
          MobileAnalyticsManager.getOrCreateInstance(
              context,
              AWSConfiguration.AMAZON_MOBILE_ANALYTICS_APP_ID,
              AWSConfiguration.AMAZON_MOBILE_ANALYTICS_REGION,
              identityManager.getCredentialsProvider(),
              new AnalyticsConfig(clientConfiguration));
    } catch (final InitializationException ie) {
      Log.e(LOG_TAG, "Unable to initalize Amazon Mobile Analytics. " + ie.getMessage(), ie);
    }

    this.pushManager =
        new PushManager(
            context,
            identityManager.getCredentialsProvider(),
            AWSConfiguration.GOOGLE_CLOUD_MESSAGING_SENDER_ID,
            AWSConfiguration.AMAZON_SNS_PLATFORM_APPLICATION_ARN,
            clientConfiguration);

    final List<String> topics = new ArrayList<String>();
    topics.add(AWSConfiguration.AMAZON_SNS_DEFAULT_TOPIC_ARN);
    topics.addAll(Arrays.asList(AWSConfiguration.AMAZON_SNS_TOPIC_ARNS));

    final String[] topicsArray = topics.toArray(new String[topics.size()]);
    pushManager.setTopics(topicsArray);

    this.syncManager =
        new CognitoSyncManager(
            context,
            AWSConfiguration.AMAZON_COGNITO_REGION,
            identityManager.getCredentialsProvider(),
            clientConfiguration);
  }