Вопрос по android – Запустите AsyncTask в TimerTask

2

Error: User Rate Limit Exceededcan't create handler inside thread that has not called looper.prepare()

timer.schedule(new ListUpdate(), helper.nextListUpdate.get(0));

class ListUpdate extends TimerTask {
    private Handler mHandler = new Handler(Looper.getMainLooper());
    public void run() {
        mHandler.post(new Runnable() {
            public void run() {
                AsyncTask<Integer, Void, Boolean> task = new updateList();
                task.execute();
            }
        });
    }
}

Error: User Rate Limit Exceeded

Error: User Rate Limit Exceeded just_user
Error: User Rate Limit ExceededrunOnUiThread() Lalit Poptani
Error: User Rate Limit Exceeded just_user
Error: User Rate Limit Exceeded Richa
Error: User Rate Limit Exceededthis oneError: User Rate Limit Exceeded Lalit Poptani

Ваш Ответ

2   ответа
0

final Handler handler = new Handler() {
    public void handleMessage(Message msg) {
        RelativeLayout rl_header = (RelativeLayout)findViewById(R.id.rl_header);
        Desktop desktop = helper.getDesktop();
        try {
            desktop.inflate(ll, rl_header, banners, DesktopApp.this);
            Collections.sort(helper.nextListUpdate);
            helper.nextListUpdate.remove(0);
            timer = new Timer();
            if (helper.nextListUpdate.size() > 0) timer.schedule(new ListUpdate(), helper.nextListUpdate.get(0));
        } catch (Exception e) {
            e.printStackTrace();
        }
     }

};

class ListUpdate extends TimerTask {
    public void run() {
        DesktopApp.this.runOnUiThread(new Runnable() {
            @Override
            public void run() {
                handler.sendEmptyMessage(0);
            }
        });
    }
}
Error: User Rate Limit Exceeded
Error: User Rate Limit Exceeded
5

AsyncTaskError: User Rate Limit Exceeded

Error: User Rate Limit Exceeded

timer.schedule(new ListUpdate(), helper.nextListUpdate.get(0));

class ListUpdate extends TimerTask {
    Looper looper = Looper.getMainLooper();
    looper.prepareMainLooper();

    private Handler mHandler = new Handler(looper);
    public void run() {
        mHandler.post(new Runnable() {
            public void run() {
                AsyncTask<Integer, Void, Boolean> task = new updateList();
                task.execute();
            }
        });
    }
}
Error: User Rate Limit Exceeded
Error: User Rate Limit Exceeded
Error: User Rate Limit Exceeded just_user
Error: User Rate Limit Exceeded
Error: User Rate Limit Exceededlooper.prepareMainLooper();Error: User Rate Limit ExceededdoInBackgroundError: User Rate Limit ExceededLooper.prepare(); Looper.loop();Error: User Rate Limit Exceededthis

Похожие вопросы