Белый экран при переходе между активити
Мне нужно чтоб после успешной регистрации пользователя его сразу кидало на гланвый экран (MainActivity). Но почему то вместо нормальной загрузки я получаю только белый экран, MainActivity не загружается.
AuthAndReg.java
public class AuthAndReg extends AppCompatActivity {
private EditText EdTextPassword, edUserEmail;
private FirebaseAuth mAuth;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_auth_and_reg);
init();
final EditText et_password = (EditText) findViewById(R.id.EdTextPassword);
final ImageButton bt_change_mode = (ImageButton) findViewById(R.id.bt_change_mode);
final TextView ChangeModText = (TextView) findViewById(R.id.ChangeModText);
bt_change_mode.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (EdTextPassword.getInputType () == 128
EdTextPassword.setInputType (129);
ChangeModText.setText ("Показывать пароль");
}
else {
EdTextPassword.setInputType (128);
ChangeModText.setText ("Скрыть пароль");
}
EdTextPassword.setSelection (EdTextPassword.getText (). length ());}});
}
@Override
protected void onStart() {
super.onStart();
FirebaseUser cUser = mAuth.getCurrentUser();
}
private void init()
{
EdTextPassword = findViewById(R.id.EdTextPassword);
edUserEmail = findViewById(R.id.edUserEmail);
mAuth = FirebaseAuth.getInstance();
}
public void onClickAuth(View view){
Intent intent = new Intent(this, AuthUser.class);
startActivity(intent);
}
public void OnClickHelp(View view)
{
Intent intent = new Intent(this, RegInfoPage.class);
startActivity(intent);
}
public void onClickReg(View view){
if(!TextUtils.isEmpty(edUserEmail.getText().toString()) && !TextUtils.isEmpty(EdTextPassword.getText().toString()) )
{
mAuth.createUserWithEmailAndPassword (edUserEmail.getText().toString(),EdTextPassword.getText().toString()).addOnCompleteListener(new OnCompleteListener<AuthResult>() {
@Override
public void onComplete(@NonNull Task<AuthResult> task) {
if(task.isSuccessful())
{
Toast.makeText(AuthAndReg.this, "Добро пожаловать, вы успешно зарегистрировались", Toast.LENGTH_SHORT).show();
Intent intent = new Intent(AuthAndReg.this, MainActivity.class);
startActivity(intent);
}
else
{
Toast.makeText(AuthAndReg.this, "Что-то пошло не так" ,
Toast.LENGTH_SHORT).show();
}
}
});
}
else
{
Toast.makeText(AuthAndReg.this, "Пожалуйста, заполните все поля" , Toast.LENGTH_SHORT).show();
}
}
public void onClickGoBack(View view){
Intent intent = new Intent(this, MainActivity.class);
startActivity(intent);
}
}
MainActivity.java
public class MainActivity extends AppCompatActivity {
private FirebaseAuth mAuth;
private TextView edUserEmail;
@Override
public void onCreate(Bundle savedInstanceState, PersistableBundle persistentState) {
super.onCreate(savedInstanceState, persistentState);
setContentView(R.layout.activity_main);
//Intent intent = getIntent();
ImageButton RegButton = (ImageButton) findViewById(R.id.RegButton);
RegButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
startActivity(new Intent(MainActivity.this, AuthAndReg.class));
}
});
}
public void buttonclick(View view){
Intent intent = new Intent(this, CatalogActivity.class);
startActivity(intent);
}
public void openRegPage(View v){
Intent intent1 = new Intent(this, AuthAndReg.class);
startActivity(intent1);
}}
activity_auth_and_reg.xml
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/regButton"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".AuthAndReg">
<EditText
android:id="@+id/edUserEmail"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:autofillHints=""
android:ems="10"
android:hint="@string/enterEmail"
android:inputType="textEmailAddress"
android:minHeight="48dp"
android:textColorHint="#757575"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/imageView9"
app:layout_constraintVertical_bias="0.04000002" />
<!-- <ImageButton-->
<!-- android:id="@+id/auth_button"-->
<!-- android:layout_width="wrap_content"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:layout_marginTop="5dp"-->
<!-- android:layout_marginBottom="40dp"-->
<!-- android:contentDescription="@string/app_name"-->
<!-- android:onClick="onClickAuth"-->
<!-- app:layout_constraintBottom_toBottomOf="parent"-->
<!-- app:layout_constraintEnd_toEndOf="parent"-->
<!-- app:layout_constraintStart_toStartOf="parent"-->
<!-- app:srcCompat="@drawable/ic_button_auth" />-->
<!-- <ImageButton-->
<!-- android:id="@+id/Reg_Button"-->
<!-- android:layout_width="wrap_content"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:layout_marginTop="50dp"-->
<!-- android:layout_marginBottom="8dp"-->
<!-- android:contentDescription="@string/app_name"-->
<!-- android:onClick="onClickReg"-->
<!-- app:layout_constraintBottom_toTopOf="@+id/auth_button"-->
<!-- app:layout_constraintEnd_toEndOf="parent"-->
<!-- app:layout_constraintHorizontal_bias="0.511"-->
<!-- app:layout_constraintStart_toStartOf="parent"-->
<!-- app:layout_constraintTop_toBottomOf="@+id/EdTextEmail"-->
<!-- app:srcCompat="@drawable/ic_button_reg" />-->
<!-- <ImageView-->
<!-- android:id="@+id/imageView"-->
<!-- android:layout_width="366dp"-->
<!-- android:layout_height="287dp"-->
<!-- android:layout_marginBottom="60dp"-->
<!-- app:layout_constraintBottom_toTopOf="@+id/edName"-->
<!-- app:layout_constraintEnd_toEndOf="parent"-->
<!-- app:layout_constraintStart_toStartOf="parent"-->
<!-- app:layout_constraintTop_toTopOf="parent"-->
<!-- app:srcCompat="@drawable/ic_def_shop" />-->
<EditText
android:id="@+id/EdTextPassword"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:autofillHints=""
android:ems="10"
android:hint="@string/firstpassword"
android:inputType="text|textPassword"
android:minHeight="48dp"
android:textColorHint="#757575"
app:layout_constraintBottom_toTopOf="@+id/RegButton"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/edUserEmail"
app:layout_constraintVertical_bias="0.00999999" />
<ImageView
android:id="@+id/imageView9"
android:layout_width="408dp"
android:layout_height="338dp"
android:layout_marginStart="15dp"
android:contentDescription="@string/app_logo1"
app:layout_constraintBottom_toBottomOf="@+id/AuthButton"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.01999998"
app:srcCompat="@drawable/ic_defshop" />
<ImageButton
android:id="@+id/AuthButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="@string/app_name"
android:onClick="onClickAuth"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/RegButton"
app:layout_constraintVertical_bias="0.04000002"
app:srcCompat="@drawable/ic_authbutton" />
<ImageButton
android:id="@+id/RegButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="@string/app_name"
android:onClick="onClickReg"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.85"
app:srcCompat="@drawable/ic_regbutton" />
<TextView
android:id="@+id/RegText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="sans-serif-black"
android:text="@string/reg_title"
android:textColor="#0E0E0E"
android:textSize="24sp"
app:layout_constraintBottom_toBottomOf="@+id/imageView9"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.050000012" />
<ImageButton
android:id="@+id/backbutton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="@string/app_name"
android:onClick="onClickGoBack"
app:layout_constraintBottom_toBottomOf="@+id/imageView9"
app:layout_constraintEnd_toStartOf="@+id/RegText"
app:layout_constraintHorizontal_bias="0.38"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.0"
app:srcCompat="@drawable/ic_gobackbutton" />
<TextView
android:id="@+id/ChangeModText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="sans-serif-medium"
android:text="@string/ShowPasswrod"
android:textColor="#272727"
app:layout_constraintBottom_toTopOf="@+id/RegButton"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.41"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/EdTextPassword"
app:layout_constraintVertical_bias="0.32999998" />
<ImageButton
android:id="@+id/bt_change_mode"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="@string/app_name"
app:layout_constraintBottom_toTopOf="@+id/RegButton"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.72"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/EdTextPassword"
app:layout_constraintVertical_bias="0.0"
app:srcCompat="@drawable/ic_button_password" />
<ImageButton
android:id="@+id/InfoButton"
android:layout_width="48dp"
android:layout_height="50dp"
android:layout_marginStart="3dp"
android:layout_marginEnd="32dp"
android:contentDescription="@string/app_name"
android:onClick="OnClickHelp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toEndOf="@+id/EdTextPassword"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.59000003"
app:srcCompat="@drawable/ic_infobutton" />
</androidx.constraintlayout.widget.ConstraintLayout>