I have a problem that appear on every new developpement.
I never found a clean way to handle it so I'm asking for your help.

Suppose you have an app that rely on data coming from network.
Every activity needs those data.

So my approach actually is to handle the download by the first activity and 
store it so it will be widely available.
No other activity will be launched before data is stored so every activity 
will be sure it will be always available.

Suppose we have the sequence
Activity A (that load data)
Then Activity B that use data
Then application goes to background
is killed by system
is wake up on B
==> No problem because data is stored so it will be available and all will 
be fine.

But, suppose that before to be waked up, data is cleared.
The application wake up on activity B with no data available.
There will be a NPE.

Of course, I can add in the OnCreate() method of application B that, if 
data is not available, launch activity A and finish.
But I also have to handle it in onResume(), on Pause(), on Create(), 
onDestroy().
And I have to make it in all my application's activities that use data 
which is not really clean.

I don't wan't that all my activities inherit from a single one.
I don't wan"t to have only one activity with lot of fragments.

The best option whould have been that the Android Application object is 
able to handle startup and change the first intent in certain conditions.
then, if we are going to run B and data is not available, lauch A instead.
but sadly, this is not possible.

So my question : How do you handle this kind of problem ?

Thanks for any advice.


Mike

-- 
-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to android-developers+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to