I have read on here that I have to use startActivityForResult() but I don't know how to exactly use it on my case, Could someone help me integrate it?
So in the MainActivity, the user logs in, from there it will start the SecondActivity and the user would be presented with two buttons, one for a third activity and the other is logging out, if the third activity is selected the user would be presented with a back button and a logout button, now the problem is that both buttons would just be going back to the second activity.
MainActivity.
public void login(View v){
EditText uname_field = (EditText) findViewById(R.id.uname_field);
EditText pword_field = (EditText) findViewById(R.id.pword_field);
username = uname_field.getText().toString();
password = pword_field.getText().toString();
if(username.equalsIgnoreCase("admin") && password.equalsIgnoreCase("admin")){
Intent intent = new Intent(this, SecondActivity.class);
startActivity(intent);
}else {
Toast.makeText(context, "Access Denied", Toast.LENGTH_SHORT).show();
}
}
Second Activity
public void logout(View v) {
finish();
}
public void viewProfile(View v){
Intent intent = new Intent(this, ThirdActivity.class);
startActivity(intent);
}
Thirdactivity
public void logout(View v) {
finish();
}
public void back(View v){
finish();
}