Click here to Skip to main content
15,877,966 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I created a simple login in android, in which user will have to input unique pin before gaining access to the app but i need more features to be implemented in the code and they are as follows
1. how to make the user log in into the app once, if the user exit the app and wants to use the app it will not ask the user to log in again to use it unless the user uninstall the app
2. how to add progress bar on the log in page, when the user click the activate button it will display for five secs before navigating to the home page if the pin entered is correct
3. how to add more unique pins in the code, any user that hsi /her pin does not tally with the listed pin will not activate the app
See my code below

public class MyActivity extends ActionBarActivity {

private static TextView tV1;
private static EditText pin;
private static Button activate;

protected void onCreate(Bundle savedInstanceState) {


public void LoginButton(){
tV1 = (TextView) findViewById(;
pin = (EditText) findViewById(;
activate = (Button) findViewById(;

activate.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
if (pin.getText().toString().equals("094523")){
Toast.makeText(MyActivity.this, "Pin is Correct",Toast.LENGTH_LONG).show();
Intent intent = new Intent("com.example.akinyemi.simplelogin.User");
}else {
Toast.makeText(MyActivity.this, "Pin is Wrong...Kindly visit our website or vendor to BUY Pin",Toast.LENGTH_LONG).show();
Kindly help

1 solution

You need to store your valid pin numbers on the system, either in a flat file or database. You can also save the application's state and then reload it in the onResume method (as described in[^]) to check whether the user has already logged in. Go to[^] where you will find lots of samples to help you.
Share this answer
Member 10627743 15-Feb-15 9:36am    
Thank you
Member 10627743 16-Feb-15 4:42am    
is it possible for me to store multiple pins on this line of code "if (pin.getText().toString().equals("094523"))//More pins here"
Richard MacCutchan 16-Feb-15 4:55am    
Not really, and it does not make much sense either. If you store these numbers as clear text then there is no security. It would be better to store them as numbers with some extra value added to make them difficult to hack. Then you just convert the pin from the user and search your table of values to see if it exists.
Member 10627743 16-Feb-15 5:02am    
Sorry for asking these questions because am still learning, can you point me to a tutorials that will allow me to store the pins with good security, because all the sqlite tutorials have seen does not show me how pre-store pins/password in the database, the user can only insert from the front end.
Richard MacCutchan 16-Feb-15 5:08am    

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900