开发者

Calling an activity after the screen password is verified---android

I am developing an application in android. I have screen password enabled. Means you have to enter a pin to unlock it.

Now , I want to call an activity, if some one enters a wrong screen password. Is it 开发者_StackOverflow中文版possible. If yes please let me know how ?

Thanks, Pravin


I don't really understand your question. Do you want to call an activity if the user enters an invalid pin (which is already configured)?

If so, just check if it's correct and launch the activity as always.

    if (checkPin(thePin)) 
        startActivity(new Intent(context,CorrectPinActivity.class));
    else 
        startActivity(new Intent(context,WrongPinActivity.class));

If you mean another thing, please comment so, and will look into it :)


Let's guess you have an edittext called "txtPassword" and have a variable "rightPassword" in which you have the correct password stored.

Just check for this:

if(txtPassword.getText().toString() == rightPassword) { // start the new activity here. } else { // alert user for wrong password. }

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜