电子邮件地址格式错误

时间:2018-03-30 06:58:55

标签: android firebase firebase-authentication

我正在使用firebase进行身份验证。在身份验证中,当我提交电子邮件和密码时,其显示的电子邮件地址格式错误 此代码工作正常但当我单击“登录”按钮时显示错误,因为电子邮件地址格式错误
请帮我解决这个错误

问题

用户输入

等输入后
  

电子邮件:mani227902@gmail.com

     

密码:123456

用户无法注册,下面的消息提示

电子邮件地址严重

package com.example.elcot.ilovetirupur;

import android.content.Intent;
    import android.support.annotation.NonNull;
    import android.support.v7.app.AppCompatActivity;
    import android.os.Bundle;
    import android.text.InputType;
    import android.text.TextUtils;
    import android.view.View;
    import android.widget.Button; 
    import android.widget.EditText;
    import android.widget.ProgressBar;
    import android.widget.Toast;

    import com.google.android.gms.tasks.OnCompleteListener;
    import com.google.android.gms.tasks.Task;
    import com.google.firebase.auth.FirebaseAuth;
    import com.google.firebase.auth.FirebaseUser;
    import com.google.firebase.auth.*;

    public class MainActivity extends AppCompatActivity implements View.OnClickListener {
    private EditText email1,pass1;
    private ProgressBar signin1;
    private Button signin,signup,forget;

    private FirebaseAuth mAuth;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        mAuth= FirebaseAuth.getInstance();
       // email1.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS);
        email1=(EditText) findViewById(R.id.email);
        pass1=(EditText) findViewById(R.id.pass);
        signin=(Button) findViewById(R.id.button2);
        signin1=(ProgressBar) findViewById(R.id.progressBar2);
        signup=(Button) findViewById(R.id.button3);
        forget=(Button) findViewById(R.id.button4);

        signin.setOnClickListener(this);
    }

    @Override
    protected void onStart()
    {
        super.onStart();
        FirebaseUser user =mAuth.getCurrentUser();
        if(user!=null)
        {
            inten();
        }
    }

    @Override
    public void onClick(View v) {

        String email=signin .getText().toString().trim();
        String pass=pass1 .getText().toString().trim();
        if (!TextUtils.isEmpty(email) && !TextUtils.isEmpty(pass))
        {
            signin1.setVisibility(View.VISIBLE);
            mAuth.signInWithEmailAndPassword(email,pass).addOnCompleteListener(new OnCompleteListener<AuthResult>() {
                @Override
                public void onComplete(@NonNull Task<AuthResult> task) {
                    if (task.isSuccessful()){
                        inten();
                    }
                    else {
                        String err=task.getException().getMessage();
                        Toast.makeText(MainActivity.this, "ERROR "+err, Toast.LENGTH_SHORT).show();
                    }
                    signin1.setVisibility(View.VISIBLE);
                }
            });
        }
    }

    private  void  inten()
    {
        Intent i= new Intent(MainActivity.this,First.class);
        startActivity(i);
        finish();
    }
}

1 个答案:

答案 0 :(得分:1)

请更改以下行

String email=signin .getText().toString().trim();

String email= email1.getText().toString().trim();

您正在通过登录按钮阅读电子邮件ID而不是电子邮件的editText

HIH