[android-developers] Data getting null when the app in background

2014-01-15 Thread Abhilash Baddam
Hi,

In my activity there are two spinners,listview and a button GO.
When the user select the options from the spinners and he clicks on GO
button there is a server request.
whatever the response comes from server i am displaying that data in
listview...
Once the data displayed, if the user keep the app in background by pressing
home..after sometime if the user again comes back to the screen
i am getting null pointer exception as the data or object passed to the
listview adapter is getting null.
Seems System is garbage collected the data... How can I overcome this
situation.

Can anyone help me on this...

-- 
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.


Re: [android-developers] Data getting null when the app in background

2014-01-15 Thread Marina Cuello
The quick solution is to check, on the onResume of your activity, if the
data is null, and if it's null, restart everything. There are other, better
ways, but that's the quickest one to code.

If you want to find better options, Google about activity life cycle and
specially recreation of activities.

Marina


On Wed, Jan 15, 2014 at 2:47 PM, Abhilash Baddam 
abhilash.androiddevelo...@gmail.com wrote:

 Hi,

 In my activity there are two spinners,listview and a button GO.
 When the user select the options from the spinners and he clicks on GO
 button there is a server request.
 whatever the response comes from server i am displaying that data in
 listview...
 Once the data displayed, if the user keep the app in background by
 pressing home..after sometime if the user again comes back to the screen
 i am getting null pointer exception as the data or object passed to the
 listview adapter is getting null.
 Seems System is garbage collected the data... How can I overcome this
 situation.

 Can anyone help me on this...

 --
 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.


-- 
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.