Sorry for the beginner, but I'm recently introducing myself in this world of programming, what happens is that I want to redirect the activity login to another activity but I do not know how, when logging in correctly, the user is validated but not redirect to another activity, why will it be?
What I mainly seek is that after sending the message that the user logged in correctly, send me directly to another activity.
Login.java:
package com.example.asus.crudaplicacion;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
public class Login extends AppCompatActivity {
EditText e1,e2;
Button b1,b2;
DatabaseHelper db;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_login);
db=new DatabaseHelper(this);
e1=(EditText)findViewById(R.id.usuario);
e2=(EditText)findViewById(R.id.password);
b1=(Button)findViewById(R.id.loguear);
b2=(Button)findViewById(R.id.segunda);
b1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String email=e1.getText().toString();
String password=e2.getText().toString();
Boolean Chkemailpass=db.emailpassword(email,password);
if(Chkemailpass==true)
Toast.makeText(getApplicationContext(),"Ha iniciado sesión correctamente",Toast.LENGTH_SHORT).show();
else
Toast.makeText(getApplicationContext(),"Email o contraseña incorrectos",Toast.LENGTH_SHORT).show();
}
});
}
}
activity_login.xml:
<?xml version="1.0" encoding="utf-8"?>
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="48dp"
android:layout_marginEnd="8dp"
android:text="LOGIN"
android:textSize="60sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.502"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<EditText
android:id="@+id/usuario"
android:layout_width="330dp"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="24dp"
android:layout_marginEnd="8dp"
android:ems="10"
android:hint="Escriba su email..."
android:inputType="textPersonName"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.21"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/textView2" />
<EditText
android:id="@+id/password"
android:layout_width="330dp"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="16dp"
android:layout_marginEnd="8dp"
android:ems="10"
android:hint="Escriba su password..."
android:inputType="textPassword"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.21"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/usuario" />
<Button
android:id="@+id/loguear"
android:layout_width="288dp"
android:layout_height="54dp"
android:layout_marginStart="8dp"
android:layout_marginTop="60dp"
android:layout_marginEnd="8dp"
android:text="Iniciar sesión"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/password" />