Modifying activity

Go to the LogInActivity.kt file, where we will input the login information. The user needs to provide a username and a password. Then this information will be searched in the Profile table of the server database. If there are the same username and password in this Profile table, you will be able to enter the MainActivity, or you will get an error message. If you are a new user, you can click New Member? to register a new profile.

First, we will check SharedPreferences to see if we have the saved username and password. It will show in the username and password fields, or it will remain blank so you can input the values. Here is the function of this logic:

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_login)

setUsernamePassword()
}

private fun
setUsernamePassword() {
if (PrefUtils.getUsername(this) != null
|| PrefUtils.getPassword(this) != null) {
username_input_login.setText(PrefUtils.getUsername(this))
password_input_login.setText(PrefUtils.getPassword(this))
}
}

Now set the OnClickListener() listener function in the TextView named need_reg, which will take us to the RegistrationActivity. Here is the code for this function:

need_reg.setOnClickListener {
val intent = Intent(this, RegistrationActivity::class.java)
startActivity(intent)
}
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.219.134.198