top of page

AP code Android Photos:

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.


2 views0 comments

Recent Posts

See All

GlobalRobotics QC

Quantum computers are a type of computing technology that use the principles of quantum mechanics to perform calculations. While...

Mindful Monday memo

Mind mapping is a visual technique that helps organize and present information in a hierarchical and interconnected manner. It is a...

Commenti


bottom of page