扩展 AsyncTask<Void、 Void、 Void>
在我的 Android 应用中,我正在执行 by extending 类中的一些操作(我在此类中执行任何 UI 都没有用处)doInBackground
AsyncTask<Void, Void, Void>
- 这是AsyncTask的正确用法吗?
- 如果是这样,我可以扩展AsyncTask吗?
- 扩展和
AsyncTask
AsyncTask<Void, Void, Void>
代码示例:
public class MessagePooling extends AsyncTask<Void, Void, Void>
{
@Override
protected Void doInBackground(Void... params)
{
while (!isCancelled())
{
//Getting data from server
SystemClock.sleep(1000);
}
return null;
}
}
艺术
public class MessagePooling extends AsyncTask
{
@Override
protected Object doInBackground(Object... params)
{
while (!isCancelled())
{
//Getting data from server
SystemClock.sleep(1000);
}
return null;
}
}
谢谢