I wrote the following code in a part of Android program, but it is not working as expected, instead it is just printing contents in variable message_2. Following is my code
public void sendCall(View view){
Intent intent1 = new Intent(this, DisplayCallActivity.class);
EditText editText = (EditText) findViewById(R.id.edit_message);
String message_2 = editText.getText().toString();
String message = "Mahesh";
//String message_1 = "Kumar";
if (message_2 == "M")
{
intent1.putExtra(EXTRA_MESSAGE, message);
startActivity(intent1);
}
else
{
intent1.putExtra(EXTRA_MESSAGE, "Unknown");
startActivity(intent1);
}
Any help on this would be appreciated
Thanks
change your condition like this
if(message_2.equals("M"))