I am build android app which is supposed to open barcode scanner screen and scan the barcode, then send the barcode string to a webservice. I have done barcode reading part, sending static strings to webservice. I am sending strings to webservice asynchronously.
here is my code
public class AsyncCallWS extends AsyncTask<String, Void, Void> {
@Override
protected Void doInBackground(String... params) {
try {
execute__barcode_webservice();
} catch (Exception e) {
// TODO: handle exception
}
return null;
}
@Override
protected void onPostExecute(Void result) {
}
@Override
protected void onPreExecute() {
}
@Override
protected void onProgressUpdate(Void... values) {
}
}
I need to pass two string to "execute__barcode_webservice()"
This is how I call asynctask to send strings.
AsyncCallWS soap_object = x.new AsyncCallWS();
soap_object.execute();
How do I pass two strings to soap_object and then to execute__barcode_webservice()
soap_object.execute(new String []{"StringOne","StringTwo"});
You can also do :
soap_object.execute("StringOne","StringTwo");
In doInBackground, params is a varargs argument, so just do :
execute__barcode_webservice(params[0], params[1]);
Try this..
AsyncCallWS soap_object = x.new AsyncCallWS();
soap_object.execute(new String []{"String_one","String_two"});
Then in doInBackground
execute__barcode_webservice(params[0],params[1]);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With