Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Android app using java. The app is of two activities: & MainActivity activity_main.cml i NewUserActivity new_account.xml The two activities are indicated below: The code part:

Android app using java. image text in transcribed
image text in transcribed
image text in transcribed
The app is of two activities: \& MainActivity activity_main.cml i NewUserActivity new_account.xml The two activities are indicated below: The code part: import androidx appcompat app AppCompatActivity; import android.os. Busdle; import android.content. Intent: import android.content. SharedPreferences; impert android.view. Vicw: import android, widget.Edit Text; impert android. widget. TextView; import android, widget. Toast; public class MainActivity estends AppConopatActivity f TextView trtv: icOverride protected void onCreate(Bundle savedinstanceState) I super.onCreate(savedinstanceState): setContentView(R. layout. activity_ main); tutv.setOnClickL istener(new View.OnClickL istener) I public void onClick(View v) If Intent i= new IntentigetApplicationContextO. NewUserActivity,class)s startActivity(i); finisha): 1): 1 public veid ustogln(View v) I Dr To lish to the the vien obyeces and nved disar EditText uname = (EditText) findVicwById(R.id. namefnp); EditText upass =( EditText ) findViewByld(R.id.pwillep ); String username w uname get Text() toString 0 ; String userpass = upass. get Text() toString); Co Te oper shamalPrek, Crwate if not exist SharedPreferences userAce = getSharedPreferences("UsersAccounts", 0); Wo Check if aser name exirts in the sharedPoyf. if ('userAcc.contains(usemame)) I Toast.make Text(getApplicationContext(). "User NOT Exists", Tonst.LENGTH_LONG) show(: retarn; 1 A ShandiPer object if (user Ace-getString(usemame, null).equals(userpass)) I Toast.make Toudget ApplicationContexto. "Aceess Authenticated", Toast.LENGIH_LONG) showO; 3 clse. Toast.makefexafgetApplicationContexu0. "Password is The code part: impert andevid a Brinche: impert android coentent hies: impert maduid virw. Yica: impert sedroid widect EArTect. impert andruid widget Toert: Shavalpulerenco wir Ace. SheredPreserisoses fidir esertadt - wer Maciodine nutarn: 1 ueeffili ovmmilo. Mainhervilycatam: tartactivilisi: finaliok 1 HW: The tacks you have to da: - Make sure you complete your lab tave. - Develop a nco activiry for updating the SharedPrefcrences data. Two taks are to be done for that: The user can access the acwly creited activity after his her credcntisls are authenticatod, se add a acc betton for that to the muin activity. By accesing the new activity, the user can mudify the password. The eade you would wite is similar to the one aboet creating a new user accoent. It is just the user name yoe have so make suee it does match before the passwond gras changol

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

More Books

Students also viewed these Databases questions