0

i want to send email verfication to the new user. i am using firebase authentication. I have tried in this way, but it's giving me problem. it's not working

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);

    if (requestCode == RC_SIGN_IN) {
        IdpResponse response = IdpResponse.fromResultIntent(data);
        System.out.println("Respuesta: "+response);


                if (resultCode == RESULT_OK) {
                    // Successfully signed in


                    if (response.isNewUser()){
                        System.out.println("Eres nuevo");
                        auth.sendEmailVerification();

Here is the error

Attempt to invoke virtual method 'com.google.android.gms.tasks.Task com.google.firebase.auth.FirebaseUser.sendEmailVerification()' on a null object reference

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
Mohamed Mamun
  • 211
  • 3
  • 15
  • Please only use the `android-studio` tag for questions about the Android Studio IDE itself. For questions about Android programming in general, use the `android` tag. – Frank van Puffelen May 24 '19 at 00:12
  • It looks lik no user is signed in, and you're calling `sendEmailVerification()` on a `null` object. See https://stackoverflow.com/questions/218384/what-is-a-nullpointerexception-and-how-do-i-fix-it – Frank van Puffelen May 24 '19 at 00:13
  • `auth` is null. Assign it before you use it. – Doug Stevenson May 24 '19 at 00:21
  • I print the result of response variable and it's showing th user info – Mohamed Mamun May 24 '19 at 00:22
  • 1
    Finally i could resolve. I create a instance of FirebaseUser under OnActivityResult.Then after check requestCode i checked if the user is new and then send email verification – Mohamed Mamun May 24 '19 at 00:34
  • You can also use this: [Authenticate with Firebase Using Email Link in Android](https://firebase.google.com/docs/auth/android/email-link-auth) – Dinesh Shingadiya May 24 '19 at 04:55

0 Answers0