I have three actvities. When I click on button they open with no problems,But when I want to open an activity by condition it is not working.
if(s2=="Both") {
Intent i = new Intent();
i.setClassName("com.gotit.babynames", "com.gotit.babynames.BabyNameActivity");
startActivity(i);
setTitle(s2);
} else if(s2=="Boys") {
Intent j = new Intent();
j.setClassName("com.gotit.babynames", "com.gotit.babynames.Boys");
startActivity(j);
setTitle(s2);
} else {
Intent k = new Intent();
k.setClassName("com.gotit.babynames", "com.gotit.babynames.Girls");
startActivity(k);
setTitle(s2);
}
Try using this:
s2 == "Both"will not compare the text in Java.You can also use this to ignore casing: