Skip to content

Commit

Permalink
Fix for a crash in logout (closes #263) (#303)
Browse files Browse the repository at this point in the history
* Fix for ActivityNotFoundException (closes #166)

* Change RESULT_OK to RESULT_CANCELED

* Fix crash in logout

* Test for a case when FragmentManager is destroyed

* Revert "Test for a case when FragmentManager is destroyed"

This reverts commit 1dfebb0.
  • Loading branch information
davidvavra authored Mar 21, 2022
1 parent d0422d3 commit 211f67d
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions library/src/main/java/com/okta/oidc/OktaResultFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import androidx.annotation.RestrictTo;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentActivity;
import androidx.fragment.app.FragmentManager;

import com.okta.oidc.net.request.web.WebRequest;

Expand Down Expand Up @@ -58,10 +59,12 @@ public static void addLogoutFragment(WebRequest request,
OktaResultFragment fragment = new OktaResultFragment();
fragment.logoutIntent = createAuthIntent(activity, request.toUri(), customTabOptions,
browsers);
activity.getSupportFragmentManager()
.beginTransaction()
.add(fragment, AUTHENTICATION_REQUEST)
.commit();
FragmentManager fragmentManager = activity.getSupportFragmentManager();
if (!fragmentManager.isDestroyed()) {
fragmentManager.beginTransaction()
.add(fragment, AUTHENTICATION_REQUEST)
.commit();
}
}

@Override
Expand Down

0 comments on commit 211f67d

Please sign in to comment.