On Tue, Nov 8, 2011 at 8:25 AM, Hitendrasinh Gohil <[email protected]
> wrote:

> Hey Treking,
>
> please read my question carefully.
>
> I am cancelling asynctask.
>

I read your question. Unless I'm blind or illiterate (very possible!), your
original post has no mention of either AsyncTask or canceling anything. You
said you had a background thread and a boolean flag.

Scenario:-
> Request has been sent to server but the response has not came yet.
> In between this time if i  do something that finishes my activity (i am
> also cancelling my asynctask.) then the method is called and trying to
> update the UI.
>

You should not calling any methods or updating the UI if the AsyncTask has
been canceled.


> I have implemeted one interface to parse the json stuff.so every time i
> make request the method is called.(No matter activity is running or not)
>
> so please suggest me better way.
>

Cancel the AsyncTask - then actually check if it's canceled or not before
doing anything.

Also, everything Streets said.

-------------------------------------------------------------------------------------------------
TreKing <http://sites.google.com/site/rezmobileapps/treking> - Chicago
transit tracking app for Android-powered devices

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to