android - why isn't my activity class's instance variable value being preserved onResume()? -
i have listview in activity b populated list of lists through adapter. list of lists retrieved bundle passed activity so:
@override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_results); lvlineups = (listview)findviewbyid(r.id.lvresults); } @override protected void onresume() { super.onresume(); lineups = (arraylist<arraylist<band>>) getintent().getserializableextra("results"); resultsadapter resultsadapter = new resultsadapter(this, lineups); lvlineups.setadapter(resultsadapter); }
i launch implicit video intent activity activity b goes in background(paused, onpause invoked) , video goes in front.
i click on video, killing activity.
activity b's resumes(onresume called) , see list of lists(lineups) empty. according activity lifecyle, activity resuming why don't still see list of lists in step 1, , how preserve after implicit video intent.
note: looks vertical listview each row horizontally scrolling list. i've gotten layout work except when adding video intent. playing video , scrolling down causes indexoutofbounds exception because lineups, bundle received activity a, gone.
@override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_results); lvlineups = (listview)findviewbyid(r.id.lvresults); lineups = (arraylist<arraylist<band>>) getintent().getserializableextra("results"); resultsadapter resultsadapter = new resultsadapter(this, lineups); lvlineups.setadapter(resultsadapter); }
after media player plays video , closes, returning activity b, see in debugger lineups empty. strange because uninitialized instance variable before oncreate called. expected remain same after video intent launched activity b, or @ least null.
ok, let go through activity cycle.
initially started activity b activity => lineups
fetched bundle of activity a. value.
then launched video
intent. going back. @ point onresume()
gets called again (where bundle has no value lineups
). should lineups
in oncreate()
rather onresume()
gets called after pause.
Comments
Post a Comment