Question: Hi, could someone please help me? I already started the program but I need to pass the username as an intent, it CANNOT be hardcoded.

Hi, could someone please help me? I already started the program but I need to pass the username as an intent, it CANNOT be hardcoded. Could someone help me fix the code?

Also, I'm using Java in Android Studio.

HERES THE PROBLEM Hi, could someone please help me? I already started the programbut I need to pass the username as an intent, it CANNOT

HERE'S MY CODE

Main activity 1

package com.example.cspasswordlab; import android.content.Intent; import android.os.Bundle; import android.view.View; import android.widget.Button; import android.widget.EditText; import androidx.appcompat.app.AppCompatActivity; //Login screen public class MainActivity extends AppCompatActivity { EditText et1,et2; Button b; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); et1=findViewById(R.id.et1); et2=findViewById(R.id.et2); b=findViewById(R.id.b); b.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { String name=et1.getText().toString(); String password=et2.getText().toString(); Intent i=new Intent(getApplicationContext(),MyWebsite.class); Intent i1=new Intent(getApplicationContext(),My_Website.class); if(name.equals("cs4322") && password.equals("123456")) { startActivity(i); } else { startActivity(i1); } } }); } } 

Main activity 2

package com.example.cspasswordlab; import android.os.Bundle; import androidx.appcompat.app.AppCompatActivity; //Welcome Screen public class MyWebsite extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_my_website); } } 

Main activity 3

package com.example.cspasswordlab; import android.content.Intent; import android.os.Bundle; import android.view.View; import android.widget.Button; import androidx.appcompat.app.AppCompatActivity; //Access Denied Screen public class My_Website extends AppCompatActivity { Button btn; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_my__website); btn=findViewById(R.id.btn); btn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Intent i=new Intent(getApplicationContext(),MainActivity.class); startActivity(i); } }); } } 

The application will let the user enter user name and password in one activity, and then display come prompt information on another activity. Here are the important characteristics: There should be two components for the user to enter the user name and password in the first activity. Each of these should have a descriptive label to the left. The two input components should appear above each other. There should be a button to cause the addition to happen in the first activity. Use a vertical linear layout with horizontal layouts to get the screen to look as much like the sample as you can. Make sure the action button is centered. Use string resources for the various labels on the application. If the inputted user name and password are matched, then display some congratulation messages on another activity. O For simplicity, set the valid user name to "cs4322, and set the password to 123456. Otherwise, display login failed messages on another activity. O In the second activity: There should be a component to display login failed information. Moreover, there should be a button placed under the display component. When the user clicks on the button, the application goes back to the previous login activity. Here are the screenshots of the lab application: 5554:Newus 5 5554 Nexus5 7:40 Login Page My Website User Name cs2302 CS2302, Welcome to my webpage! Password ...... Login QWERTYUIOP QWERTYUIO ASDFGHJKL Et B Z XCVBNM. a 5554 Nexus5 5554 News 7:41 7:42 Login Page My Website User Name abc Login Fail! Please go back, try it again! Password ...... Go Back Login QWERTYUIO QWERTYUIOP ASDFGHJKL @ Z XCVBNM Et AO e 5554 News 5554 News 7:35 7:43 My Website Login Page Login Fail! Please go back, try it again! User Name Go Back Password Login QWERTYUIO SDFGHJKL 8 2 x c v BNM. FB2 o WER Trul op ASDFGHJKL 12 XCVBNM

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!