Robert Colee <bobcolee@gmail.com>9:19 PM (8 minutes ago)
to me
//Android App Code //MainActivity.java public class MainActivity extends AppCompatActivity { private static final int LOGIN_REQUEST_CODE = 1; private static final int PAYMENT_REQUEST_CODE = 2; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); // Check if user is logged in if(!isUserLoggedIn()) { // If not, start login activity startActivityForResult(new Intent(this, LoginActivity.class), LOGIN_REQUEST_CODE); } else { // Otherwise, start payment activity startActivityForResult(new Intent(this, PaymentActivity.class), PAYMENT_REQUEST_CODE); } } @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if(requestCode == LOGIN_REQUEST_CODE) { if(resultCode == RESULT_OK) { // Login successful, start payment activity startActivityForResult(new Intent(this, PaymentActivity.class), PAYMENT_REQUEST_CODE); } else { // Login failed, show error message Toast.makeText(this, "Login failed!", Toast.LENGTH_SHORT).show(); } } else if(requestCode == PAYMENT_REQUEST_CODE) { if(resultCode == RESULT_OK) { // Payment successful, show success message Toast.makeText(this, "Payment successful!", Toast.LENGTH_SHORT).show(); } else { // Payment failed, show error message Toast.makeText(this, "Payment failed!", Toast.LENGTH_SHORT).show(); } } } private boolean isUserLoggedIn() { // TODO: Check if user is logged in return false; } } //LoginActivity.java public class LoginActivity extends AppCompatActivity { private EditText mUsernameEditText; private EditText mPasswordEditText; private Button mLoginButton; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_login); mUsernameEditText = findViewById(R.id.
Comments