0

I have a Android application where its Main activity constantly download and parse a XML from the internet using AsyncTask and update the value to UI using onPostExecute();

However,

there is a EditText which can edit value and update to XML using a button as well.

but I couldn't input any value on the EditText as the it is updated by onPostExecute(); every 3 second.

(by the time i finish input my value, it is wash out by the updated value from XML)

I have implement onClickListener(); and tried onPause(); but did not work.

How should I pause the UI update/application?

EDIT #1

Protected Void onCreate(...){
    ......
    listener();
    runnablecode.run();
}

public void run(){
    AsyncDownloader downloadxml = new AsyncDownloader();
    downloadxml.execute();
    handler.postDelay(runnablCode,poll_interval);
}
private void listener();{
    EditText atten = (EditText)findViewById(R.id.attenEditText);
    atten.setOnTouchListener(new View.OnTouchListener(){

    @Override
    public boolean onTouch(View v, MotionEvent event){
        //I want to pause UI updating the EditText here
        return false;
       }
    });
}
Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
leo
  • 5
  • 3

2 Answers2

0

pause - resume is not possible with async task. you will have to handle it with some hacks.

instead try cancel and start again after you input/process the edit text.

see Pause and Resume AsyncTasks? (Android)

Community
  • 1
  • 1
Aun
  • 1,883
  • 1
  • 17
  • 26
0

you can check if the EditText is in focus before update by async task。

ray
  • 51
  • 7