Android Registration / Registration Project

Is there a reference sample project for implementing the login / registration registration screen in Android?

I thought about what I need to know to do this:

  • Action chart
  • Text field validation
  • Text Box Tips
  • Enable / disable user interface elements (i.e. logging in only when entering data)
  • Asynchronous network request confirming credentials
  • Login pending lock
  • Redirect to next activity based on login result
  • Registration interval if the user is 1st time
  • Cancel network login if the user wants (not a failure when calling back if the user leaves the Activity)
  • Saving user data, access to token, if otherwise accessible password (and encryption)
  • Transient animations, including access feedback,
  • Use cached credentials if available
  • Login "remember me" refuse
  • and etc.

There are many more markers for writing, but you get this idea.

I suspect correct me if I am mistaken that many applications may have (or even start) a login / registration screen. Perhaps there is a customizable Eclipse project somewhere that captures most of the best practices so that developers do not reinvent the wheel a lot?

Obviously, many applications will want to do things differently. It is clear that in some cases the above is unacceptable. But .. maybe for some applications this is a reasonable "typical" login activity?

+4
source share
3 answers

The latest version of the Android Development Tools (ADT) plugin for Eclipse has a wizard to create a new LoginActivity account, which can be a good starting point. It has the following features.

  • Action flow Check text field
  • Text Box Tips
  • Enable / Disable User Interface Elements
  • Async Authentication Request
  • Login pending lock
  • Cancel Login
  • and etc.

It is in the file → New → Other → Android Activity → LoginActivity

+11
source

1) create login.xml (activity layout) in / res / layout In this example, there is an additional option to change the password

<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > <EditText android:id="@+id/username" android:hint="Username" android:layout_width="250dp" android:layout_height="wrap_content" android:layout_marginTop="180dp" android:layout_gravity="center" android:ems="10" > <requestFocus /> </EditText> <EditText android:id="@+id/password" android:layout_width="250dp" android:hint="Password" android:layout_marginTop="20dp" android:layout_gravity="center" android:layout_height="wrap_content" android:ems="10" android:inputType="textPassword" /> <Button android:id="@+id/Loginbutton" android:layout_gravity="center" android:layout_marginTop="30dp" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Login" /> <CheckedTextView android:id="@+id/changepassword" android:layout_width="wrap_content" android:layout_marginTop="75dp" android:clickable="true" android:layout_marginLeft="190dp" android:layout_height="wrap_content" android:text="Change_Login_Id" /> </LinearLayout> 

2) create the Login.java class in / src //

 public class Login extends Activity{ private Button login; private EditText Username; private EditText Password; private CheckedTextView changeid; public SQLiteDatabase sampleDB; public String COLUMN_ID="_id"; public String COLUMN1="username"; public String COLUMN2="password"; public String TABLE_NAME="Androdata"; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.login); login=(Button)findViewById(R.id.Loginbutton); Username=(EditText)findViewById(R.id.username); Password=(EditText)findViewById(R.id.password); changeid=(CheckedTextView)findViewById(R.id.changepassword); sampleDB = this.openOrCreateDatabase(TABLE_NAME, MODE_PRIVATE, null); boolean x=init(TABLE_NAME); if(x==false) { createDB(); insertDB(); } changeid.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Intent myintent=new Intent("android.intent.action.DATABASE"); startActivity(myintent); } }); login.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { int k=check(); if(k==1) { Toast.makeText(Login.this, "Login Successful ...", Toast.LENGTH_SHORT).show(); Intent myintent=new Intent("android.intent.action.CHOICE"); startActivity(myintent); } else { Username.setText(""); Password.setText(""); Toast.makeText(Login.this, "Authentication Failed...", Toast.LENGTH_SHORT).show(); } } }); } public boolean init(String tableName) { Cursor cursor = sampleDB.rawQuery("select DISTINCT tbl_name from sqlite_master where tbl_name = '"+tableName+"'", null); if(cursor!=null) { if(cursor.getCount()>0) { cursor.close(); return true; } cursor.close(); } return false; } private void insertDB() { sampleDB.execSQL("INSERT INTO " + TABLE_NAME + " Values ('1','Androviewer','viewer');"); System.out.println("Inserted data successfully...."); } private void createDB() { sampleDB.execSQL("CREATE TABLE IF NOT EXISTS " + TABLE_NAME+ "(" + COLUMN_ID + " integer primary key autoincrement, " + COLUMN1 + " text not null,"+ COLUMN2 + " text not null);"); System.out.println("Database created successfully...."); } private int check() { String a=Username.getText().toString(); String b=Password.getText().toString(); // TODO Auto-generated method stub Cursor c = sampleDB.rawQuery("SELECT username, password FROM " + TABLE_NAME + " where _id=1", null); if (c != null ) { if (c.moveToFirst()) { do { String orgusername = c.getString(c.getColumnIndex("username")); String orgpassword = c.getString(c.getColumnIndex("password")); if(a.equals(orgusername)&&b.equals(orgpassword)) { return 1; } else { return 0; } }while (c.moveToNext()); } } return 0; } } 
+3
source
 if u want a single time login u can use shared preferences or make a simple change in my db code . 1)u can set textfield hint in xml android:hint="ur hint" 2)Use Intent as i used to move forward from one activity to next. Do u need any more 
+1
source

All Articles