简体   繁体   中英

ReInitialize twitter-fabric

In MainActivity I use 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

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

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 :

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.

  2. Or how to reloadd application to get the same result and Fabric was not be initialized when I switch to new Fragment.

Thx

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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