- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
-
- // Remove the incorrect lint warnings that `getString()` might be null.
- assert getArguments() != null;
-
- // Save the host and realm in class variables.
- httpAuthHost = getArguments().getString("Host");
- httpAuthRealm = getArguments().getString("Realm");
- }
-
- // The public interface is used to send information back to the parent activity.
- public interface HttpAuthenticationListener {
- void onHttpAuthenticationCancel();
-
- void onHttpAuthenticationProceed(AppCompatDialogFragment dialogFragment);
- }
-
- // `httpAuthenticationListener` is used in `onAttach()` and `onCreateDialog()`
- private HttpAuthenticationListener httpAuthenticationListener;
-
- public void onAttach(Context context) {
- super.onAttach(context);
-
- // Get a handle for `httpAuthenticationListener` from `context`.
- try {
- httpAuthenticationListener = (HttpAuthenticationListener) context;
- } catch(ClassCastException exception) {
- throw new ClassCastException(context.toString() + " must implement `HttpAuthenticationListener`.");
- }
- }
-