如何显示的AsycncTask在doInBackground的alertDailogue(..)运行..? [英] How to show an alertDailogue in doInBackground(..) of an AsycncTask running..?

查看:142
本文介绍了如何显示的AsycncTask在doInBackground的alertDailogue(..)运行..?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

错误:获取错误与UI线程..
 当我试图展示doInBackground内的警报。有没有posibility做这个东西?

 私有类LoggingTask扩展的AsyncTask<弦乐,太虚,整数GT; {    @覆盖
    保护整数doInBackground(字符串... PARAMS){
                 //获取断绝连接,并返回状态    如果(状态== 0){
             //在这里显示一个警告....
    }
        返回状态;
    }


解决方案

  @覆盖
保护整数doInBackground(字符串... PARAMS){
    //获取断绝连接,并返回状态  publishProgress()
  @覆盖
  保护无效onProgressUpdate(虚空......值){
  // TODO自动生成方法存根
  super.onProgressUpdate(值);
 //做你想做的
    }

Error: Getting error with UI thread.. when I'm trying to show an alert inside the doInBackground. Is there any posibility do this stuff?

private class LoggingTask extends AsyncTask<String, Void, Integer> {

    @Override
    protected Integer doInBackground(String... params) {
                 //Get the sever connection and return the status

    if(status==0){
             // show an alert here....
    }
        return status;
    }

解决方案

@Override
protected Integer doInBackground(String... params) {
    // Get the sever connection and return the status

  publishProgress()
  @Override
  protected void onProgressUpdate(Void... values) {
  // TODO Auto-generated method stub
  super.onProgressUpdate(values);
 //Do what ever you want 
    }

这篇关于如何显示的AsycncTask在doInBackground的alertDailogue(..)运行..?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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