问题
Crashlytics allows strings to be sent with crash logs, but how can they be unset?
Let's say I working on a media player. Sometimes I want to send a non fatal log with a media id. Other times I want to send a log without a media id.
回答1:
You just need to pass null
as a value in the arguments
String key = "mediaId";
Crashlytics.setString(key, null);
There is check inside this method if value is null
then it will set empty string:
public void setString(String key, String value) {
// some code
value = value == null ? "" : sanitizeAttribute(value);
//some code
}
EDIT
The only way to this is reinitialize the crashlytics:
CrashlyticsCore core = new CrashlyticsCore.Builder().build();
Fabric.with(this, new Crashlytics.Builder().core(core).build());
Your kyes are stored inside CrashlyticsCore
's map
private final ConcurrentHashMap<String, String> attributes;
and there is no possibility to get those values and remove some of your keys except init it in the Builder class.
来源:https://stackoverflow.com/questions/43092495/android-crashlytics-unset-string