I am creating a simple Android App, in which the first screen would present us with an EditText and a Button, on entering “1234” (quotes not included) in the EditText and then clicking the Button, the app would transfer control to another activity.
Here is the part of the code:
final EditText enterPass;
Button submit;
enterPass = (EditText) findViewById(R.id.password);
submit = (Button) findViewById(R.id.submit);
submit.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
// TODO Auto-generated method stub
String pass = enterPass.getText().toString();
if(pass.contentEquals("1234")){
Intent adder = new Intent("com.example.pointsadder.Adder");
startActivity(adder);
}
}
});
Eclipse is not showing any error in any part of the project at all, but when I run the project, enter “1234” and click on “Submit”, I get the message: “Sorry. The application com.example.adder has unexpectedly … “
EDIT: This is the log report from DDMS:
[2012-11-08 15:27:52 - ddms] null
java.lang.NullPointerException
at com.android.ddmlib.JdwpPacket.writeAndConsume(JdwpPacket.java:213)
at com.android.ddmlib.Client.sendAndConsume(Client.java:575)
at com.android.ddmlib.HandleHello.sendHELO(HandleHello.java:142)
at com.android.ddmlib.HandleHello.sendHelloCommands(HandleHello.java:65)
at com.android.ddmlib.Client.getJdwpPacket(Client.java:672)
at com.android.ddmlib.MonitorThread.processClientActivity(MonitorThread.java:317)
at com.android.ddmlib.MonitorThread.run(MonitorThread.java:263)
Can you post your Log output ? First thing I would try is changing
pass.contentEquals("1234")just topass.equals("1234")Also try :