简体   繁体   English

重新初始化twitter-fabric

[英]ReInitialize twitter-fabric

In MainActivity I use CrashLytic 在MainActivity中,我使用CrashLytic

 @Override
    protected void onCreate(Bundle savedInstanceState) {

     if (!newUser){
           if (!Fabric.isInitialized()) 
                    Fabric.with(context, new Crashlytics());
     } else {

        goToRegistrationFrame();

     }        
   }

I switch Fragment by this code, when User try to restore his account and I'm trying to reload application 当用户尝试还原其帐户并且我尝试重新加载应用程序时,我通过此代码切换了Fragment

Intent i = getActivity().getBaseContext().getPackageManager()
                        .getLaunchIntentForPackage(getActivity().getBaseContext().getPackageName());
                i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
                i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                startActivity(i);

After reload Application it's starting from registration fragment where I'm using Digits, and setting up new Fabric parameters 重新加载应用程序后,它从我使用Digits的注册片段开始,并设置了新的Fabric参数

Fabric.with(getActivity(), new TwitterCore(authConfig),
                new Digits.Builder().withTheme(R.style.CustomDigitsTheme).build());

But unfortunatly I see that Fabric.isInitialized() is TRUE, and as a result when I call : 但是不幸的是,我看到Fabric.isInitialized()为TRUE,因此当我调用时:

Digits.authenticate(authConfigBuilder.build());

I've got this exception: 我有这个例外:

java.lang.NullPointerException: Attempt to invoke virtual method 'com.digits.sdk.android.AuthClient com.digits.sdk.android.Digits.getAuthClient()' on a null object reference

My quesyion is: 我的问题是:

  1. How to reinitialize Fabric, I know that the problem is that Fabric was setted before and not cleaned whet application was reloaded. 如何重新初始化Fabric,我知道问题在于Fabric是在设置之前设置的,而不是在重新加载应用程序后清除的。

  2. Or how to reloadd application to get the same result and Fabric was not be initialized when I switch to new Fragment. 或者,当我切换到新的Fragment时,如何重新加载应用程序以获得相同的结果,并且未初始化Fabric。

Thx 谢谢

我发现只有一种方法,可以通过此决定重新加载应用程序https://github.com/JakeWharton/ProcessPhoenix

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM