我正在开发一个安卓应用程序。我已经创建了登录页面,但它不安全。我想让这个应用程序安全。
我的代码:
Button login;
EditText username, password;
DBAdapter db = new DBAdapter(this);
static String code,loginSession;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.login);
username = (EditText) findViewById(R.id.usernametxt);
password = (EditText) findViewById(R.id.passwordtxt);
db.open();
db.insertTest("password1");
db.insertTest("password2");
db.close();
// login = (ImageView) findViewById(R.id.btnLogin);
login = (Button) findViewById(R.id.login);
login.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
String uname = username.getText().toString();
String pass = password.getText().toString();
// ---get a title---
db.open();
Cursor c = db.getAllTest();
if (c.moveToFirst()) {
do {
if (uname.equals(c.getString(1))) {
code=c.getString(1);
} else {
// Toast.makeText(getApplicationContext(),
// "Not Authenticated User..",
// Toast.LENGTH_SHORT).show();
}
} while (c.moveToNext());
}
String pwd=code+"123";
if (uname.equals("")) {
Toast.makeText(getApplicationContext(),
"Please Enter User Name.",
Toast.LENGTH_SHORT).show();
}
else if(pass.equals(""))
{
Toast.makeText(getApplicationContext(),
"Please Enter password.",
Toast.LENGTH_SHORT).show();
}
else if(uname.equals(code) && pass.equals(pwd))
{
Intent I=new Intent(loginPage.this, Test.class);
startActivity(I);
}
else if(uname!=(code)|| pass!=(pwd))
{
Toast.makeText(getApplicationContext(),
"Not Authenticated User..",
Toast.LENGTH_SHORT).show();
Intent I = new Intent(loginPage.this,loginPage.class);
startActivity(I);
}
db.close();
任何人都可以帮助我获得安全登录页面并让我知道需要遵循哪些安全登录凭据?