开发者

How do I use AsyncTask like callbackfunction

I am in a case which can be seen below that I could not find any solution.

I am going to take result value from a webmethod and set it to a parameter then after some operation with it I will send it to another webmethod and it will used by another method, etc. Here is what I want to do:

x = webMethodA();
y = webMethodB(x+3);
if(y){
z=10;
} else {
z=1000;
t = webMethodC(z);

I am using AsyncTask while calling webmethods because 开发者_运维知识库honeycomb does not support to call webservices on UI thread. I am geting the result value by onPostExecute but can not send to caller method back.

How do I overcome this problem?

setMethodName("GetTarih");
        KeyValuePair[] parameters = new KeyValuePair[2];
        parameters[0] = new KeyValuePair("Rep", "TEST001");
        parameters[1] = new KeyValuePair("Tarih", String.valueOf(Util.getOADateByToday()));
        CallSoap soap = new CallSoap(uri, soapAction, parameters);
        soap.setDataDownloadListener(new CallSoap.DataDownloadListener() {
            public void dataDownloadedSuccessfully(String data) {
                Log.e("aaaa",data);
                tarih = data;

            }
            public void dataDownloadFailed() {
                // TODO Auto-generated method stub

            }
        });

        soap.execute("");

       //I want to continue from this line with parameter named tarih.


If you're wanting to send messages/data/Bundles between threads take a look at Message and Handler classes.

Your 'worker' thread will create a message to contain the result which will be sent to your UI thread.

When you create your Handler be sure you create it in the UI thread.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜