本文整理汇总了Java中com.crashlytics.android.answers.LoginEvent类的典型用法代码示例。如果您正苦于以下问题:Java LoginEvent类的具体用法?Java LoginEvent怎么用?Java LoginEvent使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
LoginEvent类属于com.crashlytics.android.answers包,在下文中一共展示了LoginEvent类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: sendUserProperties
import com.crashlytics.android.answers.LoginEvent; //导入依赖的package包/类
@Override
public void sendUserProperties(String name, String value) {
switch (name) {
case AnalyticConstant.USER_EMAIL:
Crashlytics.setUserEmail(value);
break;
case AnalyticConstant.USER_NAME:
Crashlytics.setUserName(value);
break;
case AnalyticConstant.USER_SIGN_IN:
Answers.getInstance().logLogin(new LoginEvent().putMethod(value).putSuccess(true));
break;
case AnalyticConstant.USER_SIGN_UP:
Answers.getInstance().logSignUp(new SignUpEvent().putMethod(value).putSuccess(true));
break;
default:
Answers.getInstance().logCustom(new CustomEvent("Custom_Event").putCustomAttribute(name, value));
break;
}
}
示例2: logLogin
import com.crashlytics.android.answers.LoginEvent; //导入依赖的package包/类
public static void logLogin(Map<String, Object> attributes) {
try {
LoginEvent loginEvent = new LoginEvent();
for (Map.Entry<String, Object> entry : attributes.entrySet()) {
Object value = entry.getValue();
if (value instanceof String) {
loginEvent.putCustomAttribute(entry.getKey(), (String) value);
} else if (value instanceof Number) {
loginEvent.putCustomAttribute(entry.getKey(), (Number) value);
}
}
Answers.getInstance().logLogin(loginEvent);
} catch (IllegalStateException e) { // NOSONAR
// do nothing
}
}
示例3: test_buildAnswersLoginEvent
import com.crashlytics.android.answers.LoginEvent; //导入依赖的package包/类
@Test
public void test_buildAnswersLoginEvent()
{
LoginEvent result = logger.buildAnswersLoginEvent(loginEvent);
Map<String, Object> predefinedAttributes = PackageScopeWrappedCalls.getPredefinedAttributes(result);
assertThat(predefinedAttributes.size()).isEqualTo(2);
assertThat(predefinedAttributes).containsKey(Attributes.LogIn.METHOD);
assertThat(predefinedAttributes).containsKey(Attributes.LogIn.SUCCESS);
Map<String, Object> customAttributes = PackageScopeWrappedCalls.getCustomAttributes(result);
assertThat(customAttributes.size()).isEqualTo(1);
assertThat(customAttributes).containsKey(CUSTOM_KEY);
}
示例4: setUpSignOut
import com.crashlytics.android.answers.LoginEvent; //导入依赖的package包/类
private void setUpSignOut() {
final TextView bt = (TextView) findViewById(R.id.deactivate_accounts);
bt.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Twitter.getSessionManager().clearActiveSession();
Digits.getSessionManager().clearActiveSession();
SessionRecorder.recordSessionInactive("About: accounts deactivated");
Answers.getInstance().logLogin(new LoginEvent().putMethod("Twitter").putSuccess(false));
Answers.getInstance().logLogin(new LoginEvent().putMethod("Digits").putSuccess(false));
Toast.makeText(getApplicationContext(), "All accounts are cleared",
Toast.LENGTH_SHORT).show();
}
});
}
示例5: setUpTwitterButton
import com.crashlytics.android.answers.LoginEvent; //导入依赖的package包/类
private void setUpTwitterButton() {
twitterButton = (TwitterLoginButton) findViewById(R.id.twitter_button);
twitterButton.setCallback(new Callback<TwitterSession>() {
@Override
public void success(Result<TwitterSession> result) {
SessionRecorder.recordSessionActive("Login: twitter account active", result.data);
Answers.getInstance().logLogin(new LoginEvent().putMethod("Twitter").putSuccess(true));
startThemeChooser();
}
@Override
public void failure(TwitterException exception) {
Answers.getInstance().logLogin(new LoginEvent().putMethod("Twitter").putSuccess(false));
Toast.makeText(getApplicationContext(),
getResources().getString(R.string.toast_twitter_signin_fail),
Toast.LENGTH_SHORT).show();
Crashlytics.logException(exception);
}
});
}
示例6: setUpDigitsButton
import com.crashlytics.android.answers.LoginEvent; //导入依赖的package包/类
private void setUpDigitsButton() {
phoneButton = (DigitsAuthButton) findViewById(R.id.phone_button);
phoneButton.setAuthTheme(R.style.AppTheme);
phoneButton.setCallback(new AuthCallback() {
@Override
public void success(DigitsSession digitsSession, String phoneNumber) {
SessionRecorder.recordSessionActive("Login: digits account active", digitsSession);
Answers.getInstance().logLogin(new LoginEvent().putMethod("Digits").putSuccess(true));
startThemeChooser();
}
@Override
public void failure(DigitsException e) {
Answers.getInstance().logLogin(new LoginEvent().putMethod("Digits").putSuccess(false));
Toast.makeText(getApplicationContext(),
getResources().getString(R.string.toast_twitter_digits_fail),
Toast.LENGTH_SHORT).show();
Crashlytics.logException(e);
}
});
}
示例7: trackLoginResult
import com.crashlytics.android.answers.LoginEvent; //导入依赖的package包/类
public void trackLoginResult(boolean loginSuccess) {
Bundle bundle = new Bundle();
if (loginSuccess) {
bundle.putString(AppEventsConstants.EVENT_PARAM_VALUE_YES, String.valueOf(loginSuccess));
} else {
bundle.putString(AppEventsConstants.EVENT_PARAM_VALUE_NO, String.valueOf(loginSuccess));
}
logger.logEvent(LOGIN_EVENT, bundle);
answers.logLogin(new LoginEvent().putMethod("Digits").putSuccess(loginSuccess));
}
示例8: logLogin
import com.crashlytics.android.answers.LoginEvent; //导入依赖的package包/类
private static void logLogin(@Nullable String blogUrl, boolean success) {
if (blogUrl == null) {
blogUrl = "Unknown";
}
String successStr = success ? "SUCCEEDED" : "FAILED";
Log.i(TAG, "LOGIN %s, BLOG URL = %s", successStr, blogUrl);
Answers.getInstance().logLogin(new LoginEvent()
.putCustomAttribute("URL", blogUrl)
.putSuccess(success));
}
示例9: logSpecificEvent
import com.crashlytics.android.answers.LoginEvent; //导入依赖的package包/类
@Override
public void logSpecificEvent(@NonNull AnalyticsEvent event)
{
LoginEvent loginEvent = buildAnswersLoginEvent(event);
answers.logLogin(loginEvent);
}
示例10: buildAnswersLoginEvent
import com.crashlytics.android.answers.LoginEvent; //导入依赖的package包/类
/**
* Constructs an Answers consumable event from the given {@code AnalyticsEvent}
*
* @param event the custom event containing data to submit to the Answers framework
* @return the instantiated {@code LoginEvent} object
*/
@NonNull
LoginEvent buildAnswersLoginEvent(@NonNull AnalyticsEvent event)
{
LoginEvent loginEvent = new LoginEvent();
Map<String, Object> attributeMap = event.getAttributes();
if (attributeMap != null)
{
for (String key : attributeMap.keySet())
{
//noinspection IfCanBeSwitch (switch on String doesn't play nice on older devices)
if (key.equals(Attributes.LogIn.METHOD))
{
loginEvent.putMethod(attributeMap.get(key).toString());
}
else if (key.equals(Attributes.LogIn.SUCCESS))
{
loginEvent.putSuccess((Boolean) attributeMap.get(key));
}
else
{
loginEvent.putCustomAttribute(key, attributeMap.get(key).toString());
}
}
}
return loginEvent;
}
示例11: eventLogin
import com.crashlytics.android.answers.LoginEvent; //导入依赖的package包/类
public static void eventLogin(String method, Boolean isLoginSucceeded, Integer responseCode) {
Answers.getInstance().logLogin(new LoginEvent()
.putMethod(method)
.putSuccess(isLoginSucceeded)
.putCustomAttribute("responseCode", responseCode)
);
}
示例12: logLogin
import com.crashlytics.android.answers.LoginEvent; //导入依赖的package包/类
private static void logLogin(@Nullable String blogUrl, boolean success) {
if (blogUrl == null) {
blogUrl = "Unknown";
}
String successStr = success ? "SUCCEEDED" : "FAILED";
Timber.i("LOGIN " + successStr + ", BLOG URL = " + blogUrl);
Answers.getInstance().logLogin(new LoginEvent()
.putCustomAttribute("URL", blogUrl)
.putSuccess(success));
}
示例13: sendLogIn
import com.crashlytics.android.answers.LoginEvent; //导入依赖的package包/类
public void sendLogIn(final JSONArray data, final CallbackContext context) {
this.cordova.getActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
LoginEvent evt = new LoginEvent();
Answers.getInstance()
.logLogin(evt);
}
});
}
示例14: onResponse
import com.crashlytics.android.answers.LoginEvent; //导入依赖的package包/类
@Override
public void onResponse(Call<ResponseBody> call, Response<ResponseBody> response) {
showProgress(false);
try {
String json = response.body().string();
if (json.contains("{\"error\":")) {
userEditText.setError(json.split(":\"")[1].split("\"")[0]);
userEditText.requestFocus();
Answers.getInstance().logLogin(new LoginEvent()
.putMethod("Username")
.putSuccess(false)
.putCustomAttribute("Error", json));
} else {
/*
* {"user":"name","session":"sessionstring"} -> sessionstring
*/
Answers.getInstance().logLogin(new LoginEvent()
.putMethod("Username")
.putSuccess(true));
SyncBroadcastReceiver.scheduleNextSync(this);
String[] data = json.split(",");
String session = data[1].split(":")[1].replace("\"", "").replace("}", "").trim();
String user = data[0].split(":")[1].replace("\"", "").replace("}", "").trim();
Settings.of(this).raw().edit()
.putString("pref_session", session)
.putString("pref_user", user)
.commit();
getApplicationContext().deleteDatabase(MainDBHelper.DATABASE_NAME);
Intent intent = new Intent(this, MainActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
finish();
}
} catch (IOException e) {
e.printStackTrace();
Crashlytics.log(Log.ERROR, "LOGIN", "Error while login: " + e.toString());
Crashlytics.logException(e);
}
}