I'm using AsyncTask to fetch information from a website for a small learning project I'm doing. I've tried my code, and it "tries" do to what I intend it to do, though I have a small problem.
I'm passing a String as parameter to execute in AsyncTask, but the parameter is referenced by address instead of value. Why is this, and how do I pass a parameter between the UI thread and the background thread properly?
This is my code where the parameter is passed:
ibSearch.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
Editable artnrInput = input.getText();
String artnr = artnrInput.toString();
new Connection().execute(artnr);
}
});
I've debugged it so far and the parameter "artnr" is a value here.
This is part of my AsyncTask where the error occurs:
public class Connection extends AsyncTask<String, String, String>{
@Override
protected String doInBackground(String... artnr) {
String url = "http://mobil.systembolaget.se/SokDryck/SokDryck.aspx?artnr="+ artnr + "&lan=01";
What I want my String url to look like is this for example: http://mobil.systembolaget.se/SokDryck/SokDryck.aspx?artnr=221101&lan=01
What it does like when I debug it, making it not work is this:
http://mobil.systembolaget.se/SokDryck/SokDryck.aspx?artnr=[Ljava.lang.String;@43e4c9f8&lan=01
I have tried a simple toString(), but it was more of a guess. Why is it not passed as a value, but a reference?
Thank you, Z