织物套件的延迟初始化?

编程入门 行业动态 更新时间:2024-10-09 22:15:16
本文介绍了织物套件的延迟初始化?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

是否可以延迟初始化Fabric Kit?例如,现在我要做:

Is it possible to lazily initialize Fabric Kits? for example, right now I do:

Fabric.with(this, crashlytics, twitterCore, tweetUi); // 500ms

我只想初始化Crashlytics(没有Twitter内容),如下所示,因为它速度提高了10倍,而且我不需要立即使用Twitter。

I would like to initialize only Crashlytics (no twitter stuff), like below, because it is 10x faster, and I don't need the Twitter stuff right away

Fabric.with(this, crashlytics); // 50ms

稍后,当用户访问我需要TwitterCore&的活动时TweetUi,我想在使用它们之前将它们添加到Fabric中。

Later on, when the user visits an activity where I need TwitterCore & TweetUi, I'd like to add them to Fabric on the fly before using them.

这可能吗?

编辑: 我设法做到了反思,这显然不理想,但暂时可行。我仍在寻找适当的解决方案。这是我的操作方法:

try { final Fabric newFabric = (new Fabric.Builder(context)).kits(crashlytics, twitterCore, tweetUi).build(); final Method method = Fabric.class.getDeclaredMethod("setFabric", Fabric.class); method.setAccessible(true); method.invoke(null, newFabric); } catch (Exception e) { Timber.e(e, e.getMessage()); }

推荐答案

Fabric的Mike。当前,我们仅尊重Fabric的首次初始化。一种选择是先初始化所有内容,或者如果您可以错过一些崩溃,则不要初始化Twitter和Crashlytics,直到稍后在应用程序代码中初始化。

Mike from Fabric here. Currently, we only respect the first initialization of Fabric. One option would to be initialize everything up front or if you're ok for missing some crashes, not initialize Twitter and Crashlytics until later in your app's code.

更多推荐

织物套件的延迟初始化?

本文发布于:2023-11-12 01:53:35,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1580178.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:织物   套件   初始化

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!