com.facebook.AppEventsLogger Java Examples

The following examples show how to use com.facebook.AppEventsLogger. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: FriendPickerFragment.java    From platform-friends-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
void logAppEvents(boolean doneButtonClicked) {
    AppEventsLogger logger = AppEventsLogger.newLogger(this.getActivity(), getSession());
    Bundle parameters = new Bundle();

    // If Done was clicked, we know this completed successfully. If not, we don't know (caller might have
    // dismissed us in response to selection changing, or user might have hit back button). Either way
    // we'll log the number of selections.
    String outcome = doneButtonClicked ? AnalyticsEvents.PARAMETER_DIALOG_OUTCOME_VALUE_COMPLETED :
            AnalyticsEvents.PARAMETER_DIALOG_OUTCOME_VALUE_UNKNOWN;
    parameters.putString(AnalyticsEvents.PARAMETER_DIALOG_OUTCOME, outcome);
    parameters.putInt("num_friends_picked", getSelection().size());

    logger.logSdkEvent(AnalyticsEvents.EVENT_FRIEND_PICKER_USAGE, null, parameters);
}
 
Example #2
Source File: FriendPickerFragment.java    From Klyph with MIT License 5 votes vote down vote up
@Override
void logAppEvents(boolean doneButtonClicked) {
    AppEventsLogger logger = AppEventsLogger.newLogger(this.getActivity(), getSession());
    Bundle parameters = new Bundle();

    // If Done was clicked, we know this completed successfully. If not, we don't know (caller might have
    // dismissed us in response to selection changing, or user might have hit back button). Either way
    // we'll log the number of selections.
    String outcome = doneButtonClicked ? AnalyticsEvents.PARAMETER_DIALOG_OUTCOME_VALUE_COMPLETED :
            AnalyticsEvents.PARAMETER_DIALOG_OUTCOME_VALUE_UNKNOWN;
    parameters.putString(AnalyticsEvents.PARAMETER_DIALOG_OUTCOME, outcome);
    parameters.putInt("num_friends_picked", getSelection().size());

    logger.logSdkEvent(AnalyticsEvents.EVENT_FRIEND_PICKER_USAGE, null, parameters);
}
 
Example #3
Source File: HomeActivity.java    From barterli_android with Apache License 2.0 5 votes vote down vote up
@Override
protected void onResume() {
    super.onResume();

    // Call the 'activateApp' method to log an app event for use in analytics and advertising
    // reporting.  Do so in
    // the onResume methods of the primary Activities that an app may be launched into.
    AppEventsLogger.activateApp(this);
    if (DeviceInfo.INSTANCE.isNetworkConnected()) {
        informReferralToServer();
    }
}
 
Example #4
Source File: FriendPickerFragment.java    From barterli_android with Apache License 2.0 5 votes vote down vote up
@Override
void logAppEvents(boolean doneButtonClicked) {
    AppEventsLogger logger = AppEventsLogger.newLogger(this.getActivity(), getSession());
    Bundle parameters = new Bundle();

    // If Done was clicked, we know this completed successfully. If not, we don't know (caller might have
    // dismissed us in response to selection changing, or user might have hit back button). Either way
    // we'll log the number of selections.
    String outcome = doneButtonClicked ? AnalyticsEvents.PARAMETER_DIALOG_OUTCOME_VALUE_COMPLETED :
            AnalyticsEvents.PARAMETER_DIALOG_OUTCOME_VALUE_UNKNOWN;
    parameters.putString(AnalyticsEvents.PARAMETER_DIALOG_OUTCOME, outcome);
    parameters.putInt("num_friends_picked", getSelection().size());

    logger.logSdkEvent(AnalyticsEvents.EVENT_FRIEND_PICKER_USAGE, null, parameters);
}
 
Example #5
Source File: FriendPickerFragment.java    From android-skeleton-project with MIT License 5 votes vote down vote up
@Override
void logAppEvents(boolean doneButtonClicked) {
    AppEventsLogger logger = AppEventsLogger.newLogger(this.getActivity(), getSession());
    Bundle parameters = new Bundle();

    // If Done was clicked, we know this completed successfully. If not, we don't know (caller might have
    // dismissed us in response to selection changing, or user might have hit back button). Either way
    // we'll log the number of selections.
    String outcome = doneButtonClicked ? AnalyticsEvents.PARAMETER_DIALOG_OUTCOME_VALUE_COMPLETED :
            AnalyticsEvents.PARAMETER_DIALOG_OUTCOME_VALUE_UNKNOWN;
    parameters.putString(AnalyticsEvents.PARAMETER_DIALOG_OUTCOME, outcome);
    parameters.putInt("num_friends_picked", getSelection().size());

    logger.logSdkEvent(AnalyticsEvents.EVENT_FRIEND_PICKER_USAGE, null, parameters);
}
 
Example #6
Source File: FriendPickerFragment.java    From FacebookImageShareIntent with MIT License 5 votes vote down vote up
@Override
void logAppEvents(boolean doneButtonClicked) {
    AppEventsLogger logger = AppEventsLogger.newLogger(this.getActivity(), getSession());
    Bundle parameters = new Bundle();

    // If Done was clicked, we know this completed successfully. If not, we don't know (caller might have
    // dismissed us in response to selection changing, or user might have hit back button). Either way
    // we'll log the number of selections.
    String outcome = doneButtonClicked ? AnalyticsEvents.PARAMETER_DIALOG_OUTCOME_VALUE_COMPLETED :
            AnalyticsEvents.PARAMETER_DIALOG_OUTCOME_VALUE_UNKNOWN;
    parameters.putString(AnalyticsEvents.PARAMETER_DIALOG_OUTCOME, outcome);
    parameters.putInt("num_friends_picked", getSelection().size());

    logger.logSdkEvent(AnalyticsEvents.EVENT_FRIEND_PICKER_USAGE, null, parameters);
}
 
Example #7
Source File: FriendPickerFragment.java    From Abelana-Android with Apache License 2.0 5 votes vote down vote up
@Override
void logAppEvents(boolean doneButtonClicked) {
    AppEventsLogger logger = AppEventsLogger.newLogger(this.getActivity(), getSession());
    Bundle parameters = new Bundle();

    // If Done was clicked, we know this completed successfully. If not, we don't know (caller might have
    // dismissed us in response to selection changing, or user might have hit back button). Either way
    // we'll log the number of selections.
    String outcome = doneButtonClicked ? AnalyticsEvents.PARAMETER_DIALOG_OUTCOME_VALUE_COMPLETED :
            AnalyticsEvents.PARAMETER_DIALOG_OUTCOME_VALUE_UNKNOWN;
    parameters.putString(AnalyticsEvents.PARAMETER_DIALOG_OUTCOME, outcome);
    parameters.putInt("num_friends_picked", getSelection().size());

    logger.logSdkEvent(AnalyticsEvents.EVENT_FRIEND_PICKER_USAGE, null, parameters);
}
 
Example #8
Source File: FriendPickerFragment.java    From KlyphMessenger with MIT License 5 votes vote down vote up
@Override
void logAppEvents(boolean doneButtonClicked) {
    AppEventsLogger logger = AppEventsLogger.newLogger(this.getActivity(), getSession());
    Bundle parameters = new Bundle();

    // If Done was clicked, we know this completed successfully. If not, we don't know (caller might have
    // dismissed us in response to selection changing, or user might have hit back button). Either way
    // we'll log the number of selections.
    String outcome = doneButtonClicked ? AnalyticsEvents.PARAMETER_DIALOG_OUTCOME_VALUE_COMPLETED :
            AnalyticsEvents.PARAMETER_DIALOG_OUTCOME_VALUE_UNKNOWN;
    parameters.putString(AnalyticsEvents.PARAMETER_DIALOG_OUTCOME, outcome);
    parameters.putInt("num_friends_picked", getSelection().size());

    logger.logSdkEvent(AnalyticsEvents.EVENT_FRIEND_PICKER_USAGE, null, parameters);
}
 
Example #9
Source File: FriendPickerFragment.java    From facebook-api-android-maven with Apache License 2.0 5 votes vote down vote up
@Override
void logAppEvents(boolean doneButtonClicked) {
    AppEventsLogger logger = AppEventsLogger.newLogger(this.getActivity(), getSession());
    Bundle parameters = new Bundle();

    // If Done was clicked, we know this completed successfully. If not, we don't know (caller might have
    // dismissed us in response to selection changing, or user might have hit back button). Either way
    // we'll log the number of selections.
    String outcome = doneButtonClicked ? AnalyticsEvents.PARAMETER_DIALOG_OUTCOME_VALUE_COMPLETED :
            AnalyticsEvents.PARAMETER_DIALOG_OUTCOME_VALUE_UNKNOWN;
    parameters.putString(AnalyticsEvents.PARAMETER_DIALOG_OUTCOME, outcome);
    parameters.putInt("num_friends_picked", getSelection().size());

    logger.logSdkEvent(AnalyticsEvents.EVENT_FRIEND_PICKER_USAGE, null, parameters);
}
 
Example #10
Source File: LoginButton.java    From Klyph with MIT License 4 votes vote down vote up
@Override
public void onClick(View v) {
    Context context = getContext();
    final Session openSession = sessionTracker.getOpenSession();

    if (openSession != null) {
        // If the Session is currently open, it must mean we need to log out
        if (confirmLogout) {
            // Create a confirmation dialog
            String logout = getResources().getString(R.string.com_facebook_loginview_log_out_action);
            String cancel = getResources().getString(R.string.com_facebook_loginview_cancel_action);
            String message;
            if (user != null && user.getName() != null) {
                message = String.format(getResources().getString(R.string.com_facebook_loginview_logged_in_as), user.getName());
            } else {
                message = getResources().getString(R.string.com_facebook_loginview_logged_in_using_facebook);
            }
            AlertDialog.Builder builder = new AlertDialog.Builder(context);
            builder.setMessage(message)
                   .setCancelable(true)
                   .setPositiveButton(logout, new DialogInterface.OnClickListener() {
                       public void onClick(DialogInterface dialog, int which) {
                           openSession.closeAndClearTokenInformation();
                       }
                   })
                   .setNegativeButton(cancel, null);
            builder.create().show();
        } else {
            openSession.closeAndClearTokenInformation();
        }
    } else {
        Session currentSession = sessionTracker.getSession();
        if (currentSession == null || currentSession.getState().isClosed()) {
            sessionTracker.setSession(null);
            Session session = new Session.Builder(context).setApplicationId(applicationId).build();
            Session.setActiveSession(session);
            currentSession = session;
        }
        if (!currentSession.isOpened()) {
            Session.OpenRequest openRequest = null;
            if (parentFragment != null) {
                openRequest = new Session.OpenRequest(parentFragment);
            } else if (context instanceof Activity) {
                openRequest = new Session.OpenRequest((Activity)context);
            }

            if (openRequest != null) {
                openRequest.setDefaultAudience(properties.defaultAudience);
                openRequest.setPermissions(properties.permissions);
                openRequest.setLoginBehavior(properties.loginBehavior);

                if (SessionAuthorizationType.PUBLISH.equals(properties.authorizationType)) {
                    currentSession.openForPublish(openRequest);
                } else {
                    currentSession.openForRead(openRequest);
                }
            }
        }
    }

    AppEventsLogger logger = AppEventsLogger.newLogger(getContext());

    Bundle parameters = new Bundle();
    parameters.putInt("logging_in", (openSession != null) ? 0 : 1);

    logger.logSdkEvent(loginLogoutEventName, null, parameters);
}
 
Example #11
Source File: LoginButton.java    From KlyphMessenger with MIT License 4 votes vote down vote up
@Override
public void onClick(View v) {
    Context context = getContext();
    final Session openSession = sessionTracker.getOpenSession();

    if (openSession != null) {
        // If the Session is currently open, it must mean we need to log out
        if (confirmLogout) {
            // Create a confirmation dialog
            String logout = getResources().getString(R.string.com_facebook_loginview_log_out_action);
            String cancel = getResources().getString(R.string.com_facebook_loginview_cancel_action);
            String message;
            if (user != null && user.getName() != null) {
                message = String.format(getResources().getString(R.string.com_facebook_loginview_logged_in_as), user.getName());
            } else {
                message = getResources().getString(R.string.com_facebook_loginview_logged_in_using_facebook);
            }
            AlertDialog.Builder builder = new AlertDialog.Builder(context);
            builder.setMessage(message)
                   .setCancelable(true)
                   .setPositiveButton(logout, new DialogInterface.OnClickListener() {
                       public void onClick(DialogInterface dialog, int which) {
                           openSession.closeAndClearTokenInformation();
                       }
                   })
                   .setNegativeButton(cancel, null);
            builder.create().show();
        } else {
            openSession.closeAndClearTokenInformation();
        }
    } else {
        Session currentSession = sessionTracker.getSession();
        if (currentSession == null || currentSession.getState().isClosed()) {
            sessionTracker.setSession(null);
            Session session = new Session.Builder(context).setApplicationId(applicationId).build();
            Session.setActiveSession(session);
            currentSession = session;
        }
        if (!currentSession.isOpened()) {
            Session.OpenRequest openRequest = null;
            if (parentFragment != null) {
                openRequest = new Session.OpenRequest(parentFragment);
            } else if (context instanceof Activity) {
                openRequest = new Session.OpenRequest((Activity)context);
            }

            if (openRequest != null) {
                openRequest.setDefaultAudience(properties.defaultAudience);
                openRequest.setPermissions(properties.permissions);
                openRequest.setLoginBehavior(properties.loginBehavior);

                if (SessionAuthorizationType.PUBLISH.equals(properties.authorizationType)) {
                    currentSession.openForPublish(openRequest);
                } else {
                    currentSession.openForRead(openRequest);
                }
            }
        }
    }

    AppEventsLogger logger = AppEventsLogger.newLogger(getContext());

    Bundle parameters = new Bundle();
    parameters.putInt("logging_in", (openSession != null) ? 0 : 1);

    logger.logSdkEvent(loginLogoutEventName, null, parameters);
}