Android Crashlytics unset string

我的梦境 提交于 2021-02-10 14:14:37

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!