适用于Android中ws呼叫的通用asynctask [英] Generic asynctask for ws calls in Android

查看:70
本文介绍了适用于Android中ws呼叫的通用asynctask的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用AsyncTask类执行WS方法.我想要一个通用的异步任务类来调用WS中的任何方法.

I'm using AsyncTask class to execute WS methods. I would like to have a generic async task class to call any method in the WS.

我创建了一组可以正常工作的类,但是问题是当我必须更新UI时.我知道我可以使用对Activity类的引用来创建异步任务,然后执行所需的方法,但是我要执行的方法也是一个参数.

I create a set of classes that works fine but the problem is when I have to update the UI. I know I can create the async task with a reference to the Activity class and then execute the desired method, but what I want is the method to execute to be also a parameter.

否则,我必须为与UI交互的每种方法实现一个新类,因为每种操作因方法而异.

Otherwise I have to implement a new class for each method which interacts with the UI because each action is different depending on the method.

可能的解决方案是将侦听器与参数结合使用,但是我没有找到有关如何使用此参数的完整示例.

Provably the solution is to use Listeners combined with parameters but I didn't find a complete example of how to use this.

推荐答案

最接近的答案是您可以在同一UI中选择方法,该方法将等到后台进程结束

You can choose the method in the same UI which waits until the background process ends

这篇关于适用于Android中ws呼叫的通用asynctask的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆