Oct 2 | 7:25 PM |
Mark M. | has entered the room |
Mark M. | turned on guest access |
Oct 2 | 7:30 PM |
Gabriele | has entered the room |
Mark M. |
hello, Gabriele
|
Gabriele |
hi Mark
|
Mark M. |
how can I help you today?
|
Mark M. |
um, do you have a question? or are you just hanging out? :-)
|
Gabriele |
I've noticed that if I press Home button and then go back to the activity, using the stack, fragments of the viewpager are automatically reloaded, but if I press Home button and go back to the app, using my notify icon, then fragments are not reloaded
|
Gabriele |
eheh, yes
|
Oct 2 | 7:35 PM |
Gabriele |
is this due to lifecycle?
|
Mark M. |
by "notify icon", do you mean a Notification?
|
Gabriele |
yes, I have a "permanent" Notification icon
|
Mark M. |
unless you do something in the Intent or in the manifest, that Notification will launch another instance of your activity
|
Gabriele |
in my manifest I have: android:launchMode="singleInstance"
|
Mark M. |
sorry, I haven't played around with that
|
Gabriele |
should I use something like addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT)?
|
Gabriele |
oh, sorry
|
Mark M. |
singleTask and singleInstance "are not appropriate for most applications" (quoting the docs)
|
Gabriele |
will try to play with intent's flags
|
Mark M. |
I'd go with Intent flags, though which ones will depend a bit on your overall circumstance
|
Oct 2 | 7:40 PM |
Mark M. |
it would be either the one you list, or the combination of FLAG_ACTIVITY_NEW_TASK | FLAG_ACTIVITY_CLEAR_TASK
|
Gabriele |
oh thank you, will try it, too. Another question, currently I'm starting my service from the activity onCreate, anyway I think this is a bad thing, because there is the risk that if onCreate gets called again, I get onStartCommand called twice
|
Gabriele |
have you got some suggestion about it?
|
Mark M. |
um, is there a particular problem with onStartCommand() being called twice?
|
Gabriele |
not now, but I tought it was a bad thing
|
Gabriele |
(from a design point of view)
|
Mark M. |
well, in the command pattern for working with services, onStartCommand() may be called lots of times
|
Mark M. |
and in the binding pattern for working with services, onStartCommand() may never be called
|
Mark M. |
so, any value from 0 to N calls is valid
|
Mark M. |
whether it makes sense for your situation, I can't say, as I don't know your app
|
Gabriele |
considering that my service keep the connection to the irc server, adds data to my model and so on
|
Gabriele |
would binding pattern be better?
|
Mark M. |
I can't tell you if it will be better, as I have no basis for comparison -- again, I don't know your app
|
Oct 2 | 7:45 PM |
Mark M. |
I am merely saying that having onStartCommand() be called twice is not intrinsically a problem
|
Gabriele |
in general when is binding pattern preferred to the other?
|
Mark M. |
well, I generally prefer the command pattern
|
Mark M. |
as I like loosely coupled components
|
Mark M. |
and binding is rather tight coupling
|
Mark M. |
it also represents more state you have to manage (e.g., via a retained fragment to deal with configuration changes)
|
Mark M. |
however, you get a "real" API versus just sending commands via startService()
|
Gabriele |
ah, I see
|
Mark M. |
you might want to read through the chapters on services in the book -- I go into the details of both patterns
|
Gabriele |
yes, thank you as always
|
Gabriele |
I will read about these things to understand better which are my needs :)
|
Oct 2 | 7:50 PM |
Gabriele |
have a good evening (if it is, to you), Mark
|
Oct 2 | 7:50 PM |
Mark M. |
you too!
|
Gabriele |
we will see the next time, probably :P
|
Mark M. |
next one is Wednesday, 7:30pm US Eastern Time
|
Oct 2 | 8:30 PM |
Gabriele | has left the room |
Mark M. | turned off guest access |