I am trying to connect splash and login screen(based on firebase) but facing some problem. splash is main activity and another one is login.and one more question - in firebase auth
signInWithEmailAndPassword
how to add the third parameter like contact no.
D/OpenGLRenderer: HWUI GL Pipeline
D/: HostConnection::get() New Host Connection established 0xa1a64dc0,
tid5351
I/OpenGLRenderer: Initialized EGL, version 1.4
D/OpenGLRenderer: Swap behavior 1
W/OpenGLRenderer: Failed to choose config with
EGL_SWAP_BEHAVIOR_PRESERVED,
retrying without...
D/OpenGLRenderer: Swap behavior 0
D/EGL_emulation: eglCreateContext: 0xab1323a0: maj 3 min 0 rcv 3
D/EGL_emulation: eglMakeCurrent: 0xab1323a0: ver 3 0 (tinfo 0xab10b030)
E/eglCodecCommon: glUtilsParamSize: unknow param 0x00008cdf
glUtilsParamSize: unknow param 0x00008cdf
glUtilsParamSize: unknow param 0x00008824
E/eglCodecCommon: glUtilsParamSize: unknow param 0x00008824
D/EGL_emulation: eglMakeCurrent: 0xab1323a0: ver 3 0 (tinfo
0xab10b030)
D/AndroidRuntime: Shutting down VM
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.mainapp.tripkey, PID: 5321
java.lang.RuntimeException: Unable to start activity
ComponentInfo{com.mainapp.tripkey/com.mainapp.tripkey.login2}:
java.lang.NullPointerException: Attempt to invoke virtual method 'void
android.widget.Button.setOnClickListener(android.view.View$OnClickListener)'
on a null object reference
at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2817)
at
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2892)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1593)
at android.os.Handler.dispatchMessage(Handler.java:105)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6541)
at java.lang.reflect.Method.invoke(Native Method)
at
com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method
'void
android.widget.Button.setOnClickListener(android.view.View$OnClickListener)'
on a null object reference
at com.mainapp.tripkey.login2.onCreate(login2.java:41)
at android.app.Activity.performCreate(Activity.java:6975)
at
android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1213)
at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2770)
at
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2892)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1593)
at android.os.Handler.dispatchMessage(Handler.java:105)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6541)
at java.lang.reflect.Method.invoke(Native Method)
at
com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
Application terminated.
`
codes in login activity is =
public class login2 extends AppCompatActivity implements
View.OnClickListener
{
RelativeLayout Relative;
TextView text;
private Button login;
private Button register_here;
private EditText login_email;
private EditText login_password;
private FirebaseAuth mAuth;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_signup2);
Relative = findViewById(R.id.Relative2);
text = findViewById(R.id.textViewLOGIN);
login_email = findViewById(R.id.edit_text_Email_Address);
login_password = findViewById(R.id.edit_Text_Password);
login = findViewById(R.id.login);
register_here = findViewById(R.id.register_here);
register_here.setOnClickListener(this);
login.setOnClickListener(this);
mAuth = FirebaseAuth.getInstance();
}
private void login(){
String Email_id = login_email.getText().toString().trim();
String password = login_password.getText().toString().trim();
if (Email_id.isEmpty() ){
login_email.setError("EMAIL IS REQUIRED");
login_email.requestFocus();
return;
}
if (!Patterns.EMAIL_ADDRESS.matcher(Email_id).matches()){
login_email.setError("ENTER A VALID EMAIL");
login_email.requestFocus();
return;
}
if (password.isEmpty() ){
login_password.setError("PASSWORD IS REQUIRED");
login_password.requestFocus();
return;
}
if (password.length()<6 ){
login_password.setError("MINIMUM LENGTH OF PASSWORD SHOULD BE
6");
login_password.requestFocus();
return;
}
mAuth.signInWithEmailAndPassword(Email_id,
password).addOnCompleteListener( new OnCompleteListener<AuthResult>() {
@Override
public void onComplete(@NonNull Task<AuthResult> task) {
if (task.isSuccessful()) {
Intent activity = new Intent(login2.this,
carslayout.class);
activity.addFlags(activity.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(activity);
}
}
});
}
@Override
public void onClick(View view) {
switch (view.getId()){
case R.id.login:
login();
break;
case R.id.register_here:
Intent activit = new Intent(this,signup.class);
startActivity(activit);
break;
}
}
}''''
and splash code is -
import android.support.v7.app.AppCompatActivity;
import android.os.Handler;
import android.content.*;
import android.os.Bundle;
public class MainActivity extends AppCompatActivity {
private static int splash_time_out = 5000;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
new Handler().postDelayed(new Runnable(){
@Override
public void run(){
Intent startActivityIntent = new Intent(MainActivity.this ,
login2.class);
startActivity(startActivityIntent);
}
},splash_time_out);
}
}''''