Mark M. | has entered the room |
Mark M. | turned on guest access |
Jun 18 | 10:55 AM |
Mark M. | turned off guest access |
Jun 18 | 11:10 AM |
Mark M. | has left the room |
Jun 18 | 3:55 PM |
Mark M. | has entered the room |
Mark M. | turned on guest access |
Jun 18 | 4:00 PM |
Carlos | has entered the room |
Mark M. |
hello, Carlos!
|
Mark M. |
how can I help you today?
|
Carlos |
Hi Mark
|
Carlos |
Really quick question regarding Android back stack.
|
Jun 18 | 4:05 PM |
Carlos |
I've been having issues with my app, when I click
home button (get away from my app) and if I press the app's launcher
icon is starts at the home activity instead of the last activity I was
in.
|
Carlos |
I'm using the standard launchMode (haven't override it in manifest, etc), so not sure why this is happening.
|
Mark M. |
that's normal behavior if your process had been terminated (e.g., low memory conditions)
|
Carlos |
I even create a test app where all I do is called startActivity from one activity to the other and I see the same behavior
|
Carlos |
Based on the documentation, this might happen if
the app has been in background for a long time or like you said...if
there is low memory issues.
|
Mark M. |
again, that's normal behavior, if your process had been terminated
|
Mark M. |
there's also a developer option that controls this
|
Carlos |
However, in my case, I wait less than 5 seconds.
|
Mark M. |
do you have "Don't keep activities" turned on in Developer Options?
|
Carlos |
I noticed that the Gmail app returns to the detail
activity (email view). Do they hack around this by using TaskBuilder
possible?
|
Carlos |
possibly?
|
Mark M. |
I doubt it, as the home screen launcher icon does not know about what detail to show
|
Mark M. |
unless they are persisting that somewhere
|
Carlos |
I checked that and it was turned off. I even tried
with my old HTC incredible (2.3) who doesn't have that option and it
still behaves the same.
|
Mark M. |
:: shrug ::
|
Carlos |
Quit a few apps I personally use work as I expect
(i.e. return to detail activity) so I'm clueless as to why this only
happens with my own app, or the testcase app I created to debug this
|
Mark M. |
to confirm I'm not insane, I just ran a test with one of the book examples
|
Mark M. | |
Carlos |
SO is flooded with "use singleTask launchMode" but this clearly is not the right solution.
|
Mark M. |
worked as expected
|
Jun 18 | 4:10 PM |
Mark M. |
from first activity, tap button to bring up second
activity, press HOME, press launcher icon again, see the second
activity (because the existing process is brought back to the
foreground)
|
Carlos |
are you using the simulator?
|
Mark M. |
so, try that sample
|
Mark M. |
no, a Galaxy Nexus
|
Carlos |
Ok. I'll try your sample app.
|
Mark M. |
if the sample works as expected, see what's different between it and your test case
|
Carlos |
The only scneario that was working fine for me was if I returned to the app from the "recent apps" window.
|
Mark M. |
if the sample does not work as expected, then it's something about your environment, I guess
|
Carlos |
In that case it was returning to detail activity
|
Mark M. |
the recent tasks list will take a shot at getting
you back to the activity you had been on, even if the process went away
(I think)
|
Mark M. |
task management and the back stack is on my to-do list to run a zillion experiments and write up all the permutations
|
Mark M. |
suffice it to say, I'm not looking forward to the experience
|
Carlos |
Thanks Mark. I'll give a shot to your app. This
has been driving me crazy so at least you've confirm that it works for
you as expected. I'll double-check the developer settings on my phone
and see if Intellij forces the app to run in some sort of mode that
doesn't keep the app's latest Task in the back stack.
|
Mark M. |
ah, definitely test this sort of thing by *starting* with the app in the launcher, not as launched by an IDE
|
Mark M. |
Eclipse, at least, does its own bit of funky stuff with respect to tasks
|
Carlos |
Good to know. Thanks again Mark. I'll give it a shot this evening. That was my only question for today.
|
Jun 18 | 4:15 PM |
Mark M. |
BTW, for more on the IDE-launching problem: http://code.google.com/p/android/issues/detail?...
|
Carlos |
Cool. Thanks
|
Mark M. |
if you come up with another question, feel free to chime in
|
Jun 18 | 4:30 PM |
Carlos | has left the room |
Jun 18 | 4:45 PM |
Olga | has entered the room |
Olga |
Hello :) How are you? I took a training class with you in NY in May :)
|
Mark M. |
hello, Olga!
|
Mark M. |
I remember you!
|
Olga |
YEY :)
|
Mark M. |
how can I help you today?
|
Olga |
so, I started writing the app for my company
|
Olga |
using Viewpager and trying to use fragments(that's where it gets hairy)
|
Olga |
I make a webservice call, get the data back, parse
it and I'm displaying it but every page has the same data...i'm not
really using Fragments...cause I need to create them based on the keys i
get from JSON
|
Olga |
i'm not sure how to do that...
|
Jun 18 | 4:50 PM |
Mark M. |
don't set your PagerAdapter until you get back the
JSON, have parsed it, and therefore can teach the PagerAdapter how many
(and what) pages there are
|
Olga |
I'm using Jackson
|
Mark M. |
OK
|
Olga |
so in my mainActivity...
|
Olga |
how do I set up the fragments?
|
Olga |
Can I upload my files, so you can point me in the right direction?
|
Mark M. |
are you doing the Web service call and Jackson parsing in doInBackground() of a AsyncTask?
|
Olga |
Yes
|
Mark M. |
OK, then in onPostExecute(), call setAdapter() on the ViewPager
|
Mark M. |
where you supply a PagerAdapter that has access to your JSON-parsed data model
|
Mark M. |
so it knows how many pages there are, etc.
|
Jun 18 | 4:55 PM |
Mark M. |
you don't have a ViewPager
|
Mark M. |
but you are doing what I describe for your ListView
|
Mark M. |
you are populating the ListView with the ListAdapter in onPostExecute()
|
Mark M. |
along the same lines, if you are populating a ViewPager based upon JSON parsing, you would do that in onPostExecute() as well
|
Mark M. |
that's what the EmPubLite tutorials demonstrated
|
Mark M. |
we didn't populate the ViewPager until we loaded in the JSON (in that case, from an asset rather than a network call)
|
Olga |
don't I need to use the PagerAdapter?
|
Mark M. |
yes, you need to use a PagerAdapter with a ViewPager
|
Mark M. |
just as EmPubLite did
|
Olga |
so right now I'm kind of cheating...just passing the list and keeping track of index to display the doc in the onListItemClick()
|
Jun 18 | 5:00 PM |
Olga |
so how do I change this whole thing around to use
fragments? I need to display the list of dateDesc in the fragment and
have as many pager_title_strip as i have Document Categories...
|
Mark M. |
I can't really answer that question
|
Olga |
but when then click, to load the correct url in the webview
|
Mark M. |
I cannot really comment on your specific code
|
Mark M. |
in fact, I'm going to have to do some work to rip those uploads out of the chat
|
Mark M. |
since I'm assuming you don't want them on the public Internet
|
Olga |
how do I setAdapter() on the ViewPager?
|
Mark M. |
it's a method that you call
|
Mark M. |
if you go back to Tutorial #12, you will see where
we load the JSON and populate the pages of the ViewPager used to
display the book
|
Olga |
looking at it now :)
|
Mark M. |
however, we have reached the end of today's chat
|
Olga |
in the BookContents?
|
Mark M. |
the BookContents is the POJO data model created out of the parsed JSON
|
Mark M. |
this chat's transcript will be archived at http://commonsware.com/office-hours/ sometime soonish
|
Mark M. |
the next chat is Thursday at 10am Eastern
|
Mark M. |
have a pleasant day!
|
Olga |
you 2
|
Olga | has left the room |
Mark M. | turned off guest access |