简单登录在Android中 [英] Simple login In Android

查看:79
本文介绍了简单登录在Android中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




我在android中创建了一个简单的登录,用户必须在获得访问应用程序之前输入唯一的pin,但我需要在代码中实现更多功能它们如下所示

1.如何让用户登录到应用程序一次,如果用户退出应用程序并想要使用该应用程序,它将不会要求用户再次登录使用它除非用户卸载应用程序

2.如何在登录页面上添加进度条,当用户单击激活按钮时,它将显示五秒钟,然后导航到主页,如果输入的引脚是正确的

3.如何在代码中添加更多独特的引脚,任何hsi /她的引脚与列出的引脚不相符的用户都不会激活应用

请参阅下面的代码



公共类MyActivity扩展ActionBarActivity {



私有静态TextView tV1;

私有静态EditText引脚;

私有静态按钮激活;



@Override

protected void onCreate(Bundle savedInstanceState){

super.onCreate(savedInstanceState);

setContentView(R.layout.activity_my);



LoginButton();

}



public void LoginButton(){

tV1 =(TextView)findViewById(R.id.tV1);

pin = (EditText)findViewById(R.id.pin);

activate =(Button)findViewById(R.id.activate);



activate.setOnClickListener(new View.OnClickListener(){

@Override

public void onClick(View v){

if(pin.getText ()。toString()。equals(094523)){

Toast.makeText(MyActivity.this,Pin is Correct,Toast.LENGTH_LONG).show();

意图intent = new Intent(com.example.akinyemi.simplelogin.User);

startActivity(意图);

}否则{

Toast.makeText(MyActivity.this,Pin is Wrong ...请访问我们的网站或供应商购买Pin, Toast.LENGTH_LONG)。show();

}

}

});

}

请帮助

Hi
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;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_my);

LoginButton();
}

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

activate.setOnClickListener(new View.OnClickListener() {
@Override
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");
startActivity(intent);
}else {
Toast.makeText(MyActivity.this, "Pin is Wrong...Kindly visit our website or vendor to BUY Pin",Toast.LENGTH_LONG).show();
}
}
});
}
Kindly help

推荐答案

您需要在系统中存储有效的PIN码,无论是在平面文件还是数据库中。您还可以保存应用程序的状态,然后在 onResume 方法中重新加载它(如http://developer.android.com/training/basics/activity-lifecycle/index.html [ ^ ])检查用户是否已登录。转到 http://www.codeproject.com/KB/android/ [ ^ ]你会发现很多样本可以帮助你。
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 http://developer.android.com/training/basics/activity-lifecycle/index.html[^]) to check whether the user has already logged in. Go to http://www.codeproject.com/KB/android/[^] where you will find lots of samples to help you.


这篇关于简单登录在Android中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆