0

EDIT: Solved

I am struggling with this issue for a couple of hours and couldn't find any solution that worked for me.

So, my application crashes when I press the Send button. The firebase stuff is working fine, but when I want to display a toast message the app crashes --> excluded the stuff I wanted to do to an Activity but still crashing.

So, what can I do, that the method doSomeStuff is called correctly?

This is the method in the Sign_In Activity:

public void doSomeStuff() {
    active_user = "test";
}

This is the AppCompatDialogFragment:

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    final AlertDialog.Builder builder = new AlertDialog.Builder(getActivity(), R.style.Pop_Up_Theme);
    LayoutInflater inflater = getActivity().getLayoutInflater();
    view = inflater.inflate(R.layout.pop_up_dialog, null);

    firebaseAuth = FirebaseAuth.getInstance();

    Email = view.findViewById(R.id.EmailInput);

    Email.setText(Loading.email);
    builder.setView(view)
           .setCancelable(false)
           .setPositiveButton("Send", new DialogInterface.OnClickListener() {
                @Override
                public void onClick(final DialogInterface dialogInterface, int i) {
                    String email = Email.getText().toString().trim();
                    firebaseAuth.sendPasswordResetEmail(email)
                                .addOnCompleteListener(new OnCompleteListener<Void>() {
                                    @Override
                                    public void onComplete(@NonNull Task<Void> task) {
                                        if (task.isSuccessful()) {
                                            Sign_In.doSomeStuff();
                                            dialogInterface.cancel();
                                        } else { 
                                            //Secret stuff ;)
                                        }
                                    }
                                });
                    }
            });

    return builder.create();
} 
Tester
  • 139
  • 2
  • 8
  • 1
    what does your log say? is the doSomeStuff and the dialog in the same activity? – letsCode May 02 '18 at 19:29
  • Oh, yes forgot to say that. No, I decided to have two classes, so the Dialog is in Pop_Forgot_PW AppCompatDialogFragment and doSomeStuff is in Sign_In Activity. – Tester May 02 '18 at 20:05
  • thats why then. its because you have it inside of an activity, not a class. if you move that into the activity you r using, youll be fine. rethink about what you are working on.. but, thats why. – letsCode May 03 '18 at 15:04
  • Oh, well yesterday solved the problem without putting it into the activtiy. Thank you very much for taking your time to help me :) – Tester May 04 '18 at 12:53
  • maybe tell others what you did just in case they find this question in need of the same help? – letsCode May 04 '18 at 13:15

0 Answers0