本文整理汇总了Java中com.crashlytics.android.Crashlytics.setUserName方法的典型用法代码示例。如果您正苦于以下问题:Java Crashlytics.setUserName方法的具体用法?Java Crashlytics.setUserName怎么用?Java Crashlytics.setUserName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.crashlytics.android.Crashlytics
的用法示例。
在下文中一共展示了Crashlytics.setUserName方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setCrashlyticsKeys
import com.crashlytics.android.Crashlytics; //导入方法依赖的package包/类
public static void setCrashlyticsKeys(Context mContext) {
try {
HyperTrackLiveUser user = OnboardingManager.sharedManager(mContext).getUser();
String apiKey = ApiKey.getApiKey(mContext);
if (!HTTextUtils.isEmpty(apiKey)) {
if (user != null) {
// Set UserID
String userID = user.getId() != null ? user.getId() : "NULL";
Crashlytics.setUserIdentifier(userID);
Crashlytics.setString(CrashlyticsKeys.USER_ID, userID);
// Set UserName
String userName = !HTTextUtils.isEmpty(user.getName()) ? user.getName() : "NULL";
Crashlytics.setUserName(userName);
Crashlytics.setString(CrashlyticsKeys.USER_NAME, userName);
// Set UserPhone & UserDeviceID
Crashlytics.setString(CrashlyticsKeys.USER_PHONE, !HTTextUtils.isEmpty(user.getPhone()) ? user.getPhone() : "NULL");
String deviceUUID = com.hypertrack.lib.internal.common.util.Utils.getDeviceId(mContext);
Crashlytics.setString(CrashlyticsKeys.USER_DEVICE_ID, !HTTextUtils.isEmpty(deviceUUID) ? deviceUUID : "NULL");
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
示例2: sendUserProperties
import com.crashlytics.android.Crashlytics; //导入方法依赖的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;
}
}