Reputation: 7547
I have this code in the main Activity, where fetchxml
is an AsyncTask:
String GroupID = PreferenceManager.getDefaultSharedPreferences(MainActivity.this).getString("GroupID","");
fetchxml.execute(GroupID);
and in the doInBackground(String... paras)
, it is:
protected String doInBackground(String... paras) {
Log.d("URL+ paras[0]", paras[0]);
String xml = parser.getXmlFromUrl(URL+ paras[0]);
return xml;
}
Why I didn't get any value in paras[0]
?
Upvotes: 1
Views: 1006
Reputation: 12058
Confirm that you define your class extending AsyncTask
as:
private class Fetchxml extends AsyncTask<String, Integer, String>{ ...
The important part here is to ensure that the first parameter above is type String
to be consistent with the value expected in doInBackground
.
Also confirm that the String GroupID
is not null.
Upvotes: 1
Reputation: 11191
When the value is null or it's empty String then Log.d won't show the tag either. Make sure that sharedPreferences returns a value. It seems that the key 'GroupID' doesn't exist and sharedPreferences returns default value which is an empty String ""
Upvotes: 2