I'm new to java and I'm encountering a problem that doesn't make sense for me. I have a list view that launches an activity and the activity has to read some intent values in order to display the correct information.
// getting intent data
Intent in = getIntent();
// Get name
final String catName = in.getStringExtra("category").toString();
//Textview
TextView categorytw= (TextView)findViewById(R.id.category_name);
categorytw.setText(catName);
// Category URL
String catUrl = "";
if( catName =="Italy" ){
catUrl = "http://url .com/italy.php";
}
else if( catName =="Belgium"){
catUrl = "http://url .com/italy.php";
}
else if( catName =="France"){
catUrl = "http://url .com/france.php";
}
As You can see I get the intent value "category" and assign it to catName variable, and then I update the title textview categorytw
So far everything is good, categorytw is updated according to the value of catName.
Now I need to fetch a particular url based on the name of the category, that is why i initialize catUrl, which is empty at the beginning. Based on the value of catName, catUrl will have a different value.
This value/url is later used when I fetch some data from the url (catUrl) :
try{
XMLParser parser = new XMLParser();
String xml = parser.getXmlFromUrl(catUrl );
}
the problem is that catUrl
is always empty.
I double checked catName values.
Does anybody know what might be wrong here?