
Concept explainers
this is working in android studio .
main activity
package com.example.myapplication;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.Toast;
import android.widget.CompoundButton;
public class MainActivity extends AppCompatActivity {
private SharedPreferences sharedpreferences;
private Editor editor;
private CheckBox check;
private boolean flag;
private EditText edit1;
private EditText edit2;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
edit1 = (EditText) findViewById(R.id.editTextTextEmailAddress);
edit2 = (EditText) findViewById(R.id.editTextNumberPassword);
Button btnLogin = (Button) findViewById(R.id.btnLogin);
btnLogin.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String userName = edit1.getText().toString();
String userPassword = edit2.getText().toString();
if (check.isChecked()) {
// If the "remember password" checkbox is checked, save the username and password to shared preferences
editor.putString("account", userName);
editor.putString("password", userPassword);
editor.commit();
}
if (userName.equals(sharedpreferences.getString("account", "")) && userPassword.equals(sharedpreferences.getString("password", ""))) {
openActivity2();
} else {
Toast.makeText(MainActivity.this, "Wrong username and password", Toast.LENGTH_SHORT).show();
}
}
});
// Retrieve shared preferences and editor
sharedpreferences = getSharedPreferences("test", MODE_PRIVATE);
editor = sharedpreferences.edit();
// Retrieve the checkbox and set a listener
check = (CheckBox) findViewById(R.id.checkBox1);
check.setOnCheckedChangeListener(new CheckBox.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton arg0, boolean arg1) {
// Save the checked state of the checkbox to shared preferences
editor.putBoolean("rememberPassword", arg1);
editor.commit();
}
});
// Retrieve the rememberPassword flag from shared preferences
flag = sharedpreferences.getBoolean("rememberPassword", false);
// If rememberPassword flag is set, autofill the email and password fields
if (flag) {
edit1.setText(sharedpreferences.getString("account", ""));
edit2.setText(sharedpreferences.getString("password", ""));
check.setChecked(true);
}
}
private void openActivity2() {
Intent intent=new Intent(this, PlayerActivity2.class);
startActivity(intent);
}
}
-----
Where do I set one or some correct passwords so that it can judge whether it is true or false?
For example, the correct default password is admin@123.com, and the password is 1234. If it does not match, it is wrong.

Step by stepSolved in 2 steps

- Create a simple 6x6 android snakes and ladders game. Use gridview for layout. Use .java and .xml. for building game.arrow_forwardPlease gime solution,previos answe not working. Jva in Android studio Project named StoryProject, that plays a word game with mobile user.Add more widgets to layout resource defining UI activity. Add seven EditText widget, oneTextView, and one Button to allow mobile user to enter the following:name, age, name of the city, name of the college, profession, type of animal, pet’s nameAfter the mobile user has entered these items, the program should display the following storyinto TextView, inserting the user’s input into the appropriate locations upon clicking onButton widget labelled “Display Story” as shown hereafter in Figure:arrow_forwarda code is like this package com.example.ett;import androidx.appcompat.app.AppCompatActivity;import android.view.LayoutInflater;import android.view.View;import java.lang.reflect.Field;import androidx.recyclerview.widget.LinearLayoutManager;import androidx.recyclerview.widget.OrientationHelper;import androidx.recyclerview.widget.RecyclerView;import androidx.recyclerview.widget.StaggeredGridLayoutManager;import android.view.LayoutInflater;import android.view.View;import android.view.ViewGroup;import android.widget.TextView;import android.os.Bundle;import.NonNull;import java.util.ArrayList;import java.util.List;public class UniversityAdapter extends RecyclerView.Adapter<UniversityAdapter.ViewHolder> {private List<University> universities;public UniversityAdapter(List<University> universities) {this.universities = universities;}@NonNull@Overridepublic ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {View view =…arrow_forward
- Que 18. Design a layout in Android Studio IDE with given attributes: LinearLayout (gravity3Dcenter, orientation=vertical) TextView (text3DForm, textsize=50) TextView (text=Name) EditText (inputype=textPersonName, ems=10) TextView (text3DPassword) EditText (inputype3DtextPassword, ems=10) TextView (text=Email) EditText (inputype3DtextEmailAddress, ems=10) Button (text=sibmit)arrow_forwardFor the Shoppee app's BUY ITEM feature, which is an online shopping system, could you provide a table with use case descriptions?arrow_forwardI WANT TO CONVERT THIS JETPACK CODE INTO SWIFT UI package com.example.tastemade import androidx.compose.foundation.Imageimport androidx.compose.foundation.layout.*import androidx.compose.foundation.lazy.LazyColumnimport androidx.compose.foundation.lazy.itemsimport androidx.compose.material3.Buttonimport androidx.compose.material3.Cardimport androidx.compose.material3.ExperimentalMaterial3Apiimport androidx.compose.material3.MaterialThemeimport androidx.compose.material3.Textimport androidx.compose.runtime.Composableimport androidx.compose.ui.Alignmentimport androidx.compose.ui.Modifierimport androidx.compose.ui.graphics.painter.Painterimport androidx.compose.ui.layout.ContentScaleimport androidx.compose.ui.res.painterResourceimport androidx.compose.ui.text.style.TextAlignimport androidx.compose.ui.tooling.preview.Preview-import androidx.compose.ui.unit.dpimport androidx.navigation.NavHostControllerimport androidx.navigation.NavTypeimport androidx.navigation.compose.NavHostimport…arrow_forward
- Create a 2D board game using java AWT and mouse event. Keep it simple and original. Neat code pleasearrow_forwardMake a layout in Android Studio as shown in the blueprint shown below: Requirements 1. Imageview 2. Three Textviews with their names as (Name, DOB, Country) 3. Button 4. Progressbararrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education





