Ah thanks Streets Of Boston, I did not know about that guarantee. That
surely does make it easier and avoids losing updates.

Andrew

On 9 June 2010 02:29, Streets Of Boston <flyingdutc...@gmail.com> wrote:
> I report the result by using onPostExecute.
>
> Android guarantees that during a configuration change, no message will
> be posted to 'the' activity inbetween an onDestroy and an onCreate (i
> remember a post by Dianna about this).
>
> This means that the result from the onPostExecute either arrives
> before the activity is destroyed or after it is created (during a
> configuration change).
>
> I give the requests unique IDs and save these IDs within the 'last-
> configuration-change' object. When the onCreate is called, i get the
> 'last-configuration-change' object and restore these IDs in the new
> activity instance.
>
> When the onPostExecute finishes, it queries which activity of the
> expected class is on top of the activity stack of my app. If it finds
> one, the result is sent to this activity and handled by it. If it
> can't find one, the activity has been paused (hidden) or permanently
> destroyed and the user is no longer interested in the result.
>
>
> On Jun 8, 7:45 pm, Andrew Brampton <bramp...@gmail.com> wrote:
>> On 9 June 2010 00:02, Streets Of Boston <flyingdutc...@gmail.com> wrote:
>>
>> > "However, that approach can still lose responses or duplicate network
>> > usage if the Activity is destroyed/created while the AsyncTask is
>> > doing its job"
>>
>> > Is that an issue with the Droid-fu or with AsyncTask?
>> > I don't have that issue. When configuration changes take place, no new
>> > requests are duplicated and existing ones just keep going, as long as
>> > you put the AsyncTasks in a static context (not an (activity) instance
>> > context).
>>
>> Maybe I'm making an assumption about how you are using AsyncTask, but
>> what happens in the gap between the old Activity being destroyed and
>> before the new one has been created. What happens to the result in
>> that gap as you have no valid Activity to display the result? Either
>> you are losing your response, or you have to re-request it (hence
>> duplicate network usage). Or I guess you could be storing the result
>> temporary in your Application class?
>>
>> Andrew
>
> --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to android-developers@googlegroups.com
> To unsubscribe from this group, send email to
> android-developers+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en

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

Reply via email to