Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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 PROBLEMimage text in transcribedimage text in transcribed

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Concepts

Authors: David Kroenke, David Auer, Scott Vandenberg, Robert Yoder

9th Edition

0135188148, 978-0135188149, 9781642087611

More Books

Students also viewed these Databases questions

Question

How does the EEOC interpret the national origin guidelines?

Answered: 1 week ago

Question

What is the purpose of the OFCCP?

Answered: 1 week ago