我有这样一种情况,我想为Android的Crashlystic添加一些日志,但并不总是发送它。然后在返回到同一函数之前,我想清除日志。对于这一点,我似乎找不到如何做到这一点的方法。以下是该情况的说明:
public foo() {
bar();
bar();
bar();
}
public bar() {
// Clear log here, but I don't know how
...
// Add new log here.
Crashlytics.log(1, "TAG", "log information");
Crashlytics.log(1, "TAG", "log information");
Crashlytics.log(1, "TAG", "log information");
if (condition) {
Crashlytics.logException(new Exception("Throwing the actual non fatal error to log"));
}
}
问题在于,如果不清除日志,下一次实际的非致命性崩溃将包含所有未打算发送的时间内的所有日志。我只需要最后一次调用
bar()
的日志。
String
设置为null,但我们不能将int
设置为null。那么如何重置int
、float
、long
和double
为null呢?如何重置这些键? - Bugs Happen