Java 在Android中检查密码

Java 在Android中检查密码,java,android,login,android-activity,passwords,Java,Android,Login,Android Activity,Passwords,我想检查密码,我在Android中有一个密码字段 package com.example.berk4; import android.os.Bundle; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; import android.widget.EditText; import androi

我想检查密码,我在Android中有一个密码字段

    package com.example.berk4;

    import android.os.Bundle;
    import android.view.View;
    import android.view.View.OnClickListener;
    import android.widget.Button;
    import android.widget.EditText;
    import android.app.Activity;
    import android.app.AlertDialog;
    import android.content.Intent;


    public class MainActivity extends Activity implements OnClickListener{



@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    EditText et = (EditText)findViewById(R.id.editText1);
    Button buttonEnter = (Button)findViewById(R.id.button1);
    buttonEnter.setOnClickListener(this);


}

@Override
public void onClick(View v) {
    EditText et = (EditText)findViewById(R.id.editText1);
    String password = et.getText().toString();

    et.getEditableText().toString();
    if (password.equals("admin")) {
        Intent intent2 = new Intent("com.example.berk4.screen2");
    startActivity(intent2);

    }else{

        AlertDialog.Builder builder = new AlertDialog.Builder(this);
        builder.setTitle("you suck");
        builder.setMessage("try again");
        builder.setPositiveButton("ok", null);
        AlertDialog dialog = builder.show();
    }

}

}

当我写一个随机错误的密码时,它工作正常,但当我写正确的密码时,应用程序关闭,为什么它对我不起作用?(顺便说一句,我有另一个类屏幕2。)

开始新活动,就好像密码正确一样:

 if (password.equals("admin")) {
        Intent intent2 = new Intent(MainActivity.this,screen2.class);
        startActivity(intent2);

    }else{
    // your code here
  }
还要确保您已将下一个活动添加到
AndroidManifest.xml
中,如下所示:

.....
<activity android:name=".screen2"></activity>
</application>
.....
。。。。。
.....

是否已将screen2活动添加到清单文件?是否已将screen2活动添加到清单xml中?