Tuesday, 20 August 2013

Android getStringExtra problems

Android getStringExtra problems

I am passing a string from one activity to the other. I pass the text
"maglist". When i log the string in the next activty it says "maglist" as
it should do. BUT, if i do an if statement which asks if the string =
"maglist" then is just goes to the else when it should be true. Il show
you:
First Activity:
Intent intentRefresh = new Intent(getApplicationContext(),
com.fieldandrurallife.media.InternetRefresh.class);
String list = "maglist";
intentRefresh.putExtra("from", list);
intentRefresh.putExtra("cat", cat);
startActivity(intentRefresh);
Second Activity:
Intent iB = getIntent();
String from = iB.getStringExtra("from");
if(from == "maglist"){
Log.d("refresh", "From = " + from);
} else {
Log.d("refresh", "dident work" + from);
}
I get the LOG of "dident work maglist" when it should be "maglist"
Confused. Thanks in advanced.

No comments:

Post a Comment