Jan 10 | 3:55 PM |
Mark M. | has entered the room |
Mark M. | turned on guest access |
Marcin | has entered the room |
Mark M. |
howdy, Marcin!
|
Mark M. |
how can I help you today?
|
Marcin |
Hi Mark
|
Marcin |
I have a no UI Activity with Loader.
|
Mark M. |
by "no UI Activity", do you mean Theme.NoDisplay?
|
Aaron | has entered the room |
Mark M. |
(BTW, hi, Aaron -- I will be with you shortly!)
|
Marcin |
To be more precise I have actionbar with two tabs
|
Jan 10 | 4:00 PM |
Aaron |
Hello. Sounds good
|
Marcin |
and my activity basically just setups fragments with listviews for both
|
Marcin |
tabs
|
Marcin |
then Loader runs after a button is pressed in actionbar and when it is finished it refreshes fragment with a listview in Tab A.
|
Marcin |
when loader is finished, Activity has a listener to it which finds listview fragment
|
Marcin |
and forces its list to reload.. it happens like this
|
Marcin |
View paste
|
Mark M. |
that doesn't force the list to reload -- it forces the Loader to reload
|
Marcin |
it all works fine
|
Marcin |
true
|
EGHDK | has entered the room |
Marcin |
the problem appears when i rotate the device
|
Marcin |
mlf can not be found
|
Mark M. |
(BTW, howdy, EGHDK -- be with you in a few minutes)
|
Marcin |
i can see that the initial loader (started from actionbar button) works properly
|
Mark M. |
are you sure that you are not removing that fragment somewhere?
|
Marcin |
in my onCreate Activity
|
Marcin |
i have
|
Marcin |
if(savedInstance == null){..}
|
Marcin |
and then
|
Marcin |
View paste
|
Jan 10 | 4:05 PM |
Marcin |
so that this piece of code always fires (also on orientation change)
|
Marcin |
my on tab selected is typical
|
Marcin |
View paste
(2 more lines)
|
Mark M. |
first, if
getSupportFragmentManager().findFragmentById( android. R. id. content);
is returning null, then either you never selected a tab, or somewhere
you are removing/detaching the fragment from the tab
|
Mark M. |
second, the code you are executing there does not need the fragment anyway, since fragments use the activity's LoaderManager
|
Mark M. |
just get rid of the mlf. and do
getLoaderManager().getLoader(0).forceLoad();, if you are sure that is
the code that should be executed in this condition
|
Mark M. |
let me take questions from the others, and I will be back with you in a bit
|
Mark M. |
Aaron: do you have a question?
|
Marcin |
thanks for suggestions Mark, will run some quick tests
|
Jan 10 | 4:10 PM |
Mark M. |
OK, Aaron, if you return, chime in
|
Mark M. |
EGHDK: do you have a question?
|
EGHDK |
Hmm... I will go ahead and ask mine.
|
EGHDK |
Yep.
|
EGHDK |
I have compiled a nice little list of "small" questions.
|
Aaron |
go for it.. Ill jump in next. I only really have 1 question right now.
|
Mark M. |
EGHDK: go ahead with the first one
|
EGHDK |
My first "problem" is that I finish my
main_activity (my only activity). But when I press the "recent apps"
button/multitasking button, I see the picture of that activity
|
Mark M. |
of course
|
EGHDK |
And if I click that little icon, it still comes up to that screen.
|
Mark M. |
yup, that's perfectly normal
|
Aaron |
Hey Mark. I have been working with maps v2. I have
been working out all my problems before i put together a full project.
In one of my test programs i wanted to test the use of
supportmapfragments. I created a project that added 2 fragments to a
container and hides one of them. I put 2 different markers on each map
to make sure i knew which one was showing.
|
Aaron |
woops sry didnt mean to press enter.
|
Jan 10 | 4:15 PM |
EGHDK |
So I can write `this.finish();` and the application will close, but I can still open it up. So does it ever actually finish()?
|
Mark M. |
it finished when you called finish()
|
Mark M. |
and then another copy was created when the user tapped the entry in the recents list
|
Mark M. |
and that one will finish when the user presses BACK or you call finish()
|
Mark M. |
and if the user taps the entry in recents again, yet another copy will be created
|
Mark M. |
ad nauseum
|
EGHDK |
Any way to "stop" that?
|
Mark M. |
stop what?
|
Mark M. |
if the user launches your app, they would like it to launch
|
EGHDK |
But it launches to something that shouldn't be there.
|
Mark M. |
that statement makes no sense
|
EGHDK |
Hahaha.
|
EGHDK |
Okay, let me rephrase this whole thing.
|
EGHDK |
What I really want it to do, it when they click the app, I don't want it to start at that specific spot of the application.
|
Jan 10 | 4:20 PM |
EGHDK |
I would like for them to get redirected to the home screen of the application.
|
Mark M. |
first, why?
|
EGHDK |
Even though that doesn't make sense for 99% of apps, it seems practical in my application.
|
Aaron |
can i save the quote?
|
Aaron |
that quote.
|
Mark M. |
EGHDK: you can try playing around with stuff like
android:finishOnTaskLaunch or something to change this behavior, but I
do not have a solid recipe for it
|
Mark M. |
let me take questions from the others, and I'll be back with you shortly
|
Aaron |
ok :) yay
|
Mark M. |
Aaron: OK, I've read what you posted above... please continue
|
Aaron |
View paste
|
Mark M. |
um, I haven't the foggiest notion what might be going on
|
Mark M. |
if you can create a sample project that reproduces the error, I can try looking at it
|
Mark M. |
IIRC, you posted a StackOverflow question on this -- right?
|
Aaron |
ya
|
Aaron |
I have been able to use replace.
|
Jan 10 | 4:25 PM |
Aaron |
but that defeats the purpose of loading in the mapfragments
|
Mark M. |
what do you mean "that defeats the purpose..."?
|
Aaron |
Interesting.
|
David O. | has entered the room |
EGHDK |
Hey Mark, regarding "android:clearTaskOnLaunch"
would that be set on the mainActivity or on the Activity that I do not
want anyone to get to once it finishes().
|
David O. |
Hello
|
Mark M. |
for example, if you use ViewPager, it will do add() and remove()
|
Mark M. |
(David: hi! I will be with you shortly)
|
David O. |
Thank you
|
Aaron |
ya i was working with your book example and saw the viewpager .
|
Mark M. |
(EGHDK: from the docs, I'd say your home activity would have this flag)
|
Aaron |
I was thinking of using it for the map views but i dont need the swiping.
|
Mark M. |
my point is that add()/remove()/replace() should not intrinsically be a problem
|
Mark M. |
since that's the stuff that FragmentPagerAdapter and such use
|
Mark M. |
so I am trying to understand why this "defeats the purpose"
|
Aaron |
OK. I will just revert to replace. Crazy issue though. I am glad that it is not some trivial stupid thing that i am missing.
|
Aaron |
since it works.
|
Aaron |
Thankyou good sir.
|
EGHDK |
Just chiming in here. I hate fragments, I had the
biggest issues with remove(). It never seemed to work. Then I just
started using hide() and everything was peachy.
|
Mark M. |
they may be using SurfaceView, which has... odd effects when there are multiple of them floating around
|
Mark M. |
David: your turn! do you have a question?
|
David O. |
I have a few questions actually, but they are short
|
Mark M. |
shoot me your first one
|
David O. |
first question: is there a broadcast reciever to listen for changes in network states?
|
Jan 10 | 4:30 PM |
David O. |
e.g. going from an unconnected state to a connected one?
|
Aaron |
EGHDK I actually tried using hide() it doesnt work with map fragments.
|
Mark M. |
David: see ConnectivityManager
|
Mark M. | |
David O. |
thanks
|
Mark M. |
since that was really quick, fire me your next one
|
David O. |
is the latest version of actionbar sherlock compatible with the latest support library?
|
Mark M. |
AFAIK, yes
|
David O. |
i saw on stack overflow that you have something on github
|
David O. |
using both
|
Mark M. |
leastways, I am running with that combination and haven't run into a problem
|
David O. |
It was in response to a question about embedding fragments
|
Mark M. |
pretty much all the samples that use ActionBarSherlock are using the latest Android Support package JAR
|
Mark M. |
again, I haven't run into any issues
|
David O. |
so i shouldn't have to add the v17 support library seperately?
|
David O. |
ok thank you
|
Mark M. |
v17?
|
Aaron |
v4 or v13 i though
|
Aaron |
t
|
Mark M. |
there is no v17
|
Mark M. |
there is v4 and v13 as JARs
|
David O. |
i mean v4
|
Mark M. |
plus a v7 that's actually an Android library project (for GridLayout)
|
David O. |
i want to be able to use getChildFragment manager
|
Mark M. |
any project using ActionBarSherlock needs an Android Support package v4 JAR
|
Mark M. |
you are welcome to use the latest if you wish
|
David O. |
thank you
|
EGHDK |
Oh that reminds me. My second question to Mark. On
SO a very long time ago. Probably around 8+ months, I was completely
new to android, and I said that it was stupid that they do not
automatically include the support library. You stated that (If I
remember correctly) that not everyone needed to support all the older
versions, so they do not include it automatically. Have they changed
that? I'm pretty sure every app I start, has the compat jar.
|
Mark M. |
Marcin: do you have another question
|
Marcin |
yes
|
Marcin |
its actually continuing on the first one
|
Mark M. |
(EGHDK: that's a matter of the particular activity wizard you chose)
|
Marcin |
to add to your comments
|
Jan 10 | 4:35 PM |
Aaron |
Every time i use ABS i have to include the latest ABS and remove support lib v4 from my libs folder.
|
Marcin |
to your first comment : onTabSelected fires before "code looking for mlf"
|
Marcin |
to your second comment : from my test it seems that fragment loaders are different than activity loaders
|
Mark M. |
it's possible that a config change fires onTabUnselected(), though
|
Marcin |
it does not appear in lofs
|
Marcin |
logs
|
Mark M. |
since you are using add() in onTabSelected(), I presume you are doing remove() in onTabUnselected()
|
Marcin |
View paste
|
Aaron |
Have a good day everyone. Good Lunk in your projects. And Thankyou Mark.
|
Mark M. |
Marcin: I cannot explain the behavior that you are seeing and have no good way really of assisting you
|
Aaron | has left the room |
Marcin |
ok, can I have another question then?
|
Mark M. |
sure
|
Marcin |
How would you implement 3tabs with actionbar navigation? each tab having a separate backstack of fragments
|
Mark M. |
personally, I am not a fan of tabs having distinct back stacks
|
Jan 10 | 4:40 PM |
Mark M. |
that being said, you'd have to manage all of that yourself
|
Mark M. |
as Android only manages a back stack on an activity basis, not a per-tab basis
|
Marcin |
what is the proper ux then here? any apps that you could point to in market as examples?
|
Mark M. |
for an activity with tabs, BACK exits the activity
|
Mark M. |
as is done by probably 99% of apps on the market that use tabs in any form
|
Mark M. |
the only *exception* is in the case of a browser with visible tabs, where BACK is overridden to have meaning within the app
|
Mark M. |
and they aren't using a fragment back stack for that, unless I miss my guess
|
Marcin |
ok.. will have to think about it harder
|
Marcin |
thanks
|
Mark M. |
EGHDK: do you have another question?
|
Marcin |
regarding your second comment on my first question
|
Marcin |
View paste
|
Marcin |
from docs
|
Mark M. |
(Marcin: and if you look at the source code, it gets that from the activity)
|
Marcin |
maybe :) but mlf.getLoadermanager.getL and simple getLoaderManager.getL run different loaders
|
Marcin |
first from fragment, second from activity
|
Mark M. |
David: do you have another question?
|
Jan 10 | 4:45 PM |
David O. |
yes...another general question
|
David O. |
is it safe to use two annotation libraries?
|
Mark M. |
um, I have no idea
|
Mark M. |
I would assume so
|
David O. |
I would like to use ORMLite and GSON annotation library
|
Mark M. |
after all, Android has its annotations, and third
party JARs might add their own, and I haven't heard about Android's
annotations breaking all those others
|
Mark M. |
if they have name collisions there could be issues
|
David O. |
thank you
|
Mark M. |
EGHDK: do you have another question?
|
EGHDK |
Yes,
|
EGHDK |
In reference to the support library again.
|
EGHDK |
When I'm writing some application, how do I know if the support library should be used or not?
|
EGHDK |
I had an example but forgot. heh.
|
Mark M. |
if you are trying to use an android.support.v4 class, directly or indirectly (e.g., via ActionBarSherlock), you need the v4 JAR
|
Mark M. |
if you are trying to use an android.support.v13 class, you need the v13 JAR
|
EGHDK |
Oh. Like notificationcompat.
|
Mark M. |
right
|
EGHDK |
I remember doing a whole bunch of notification stuff, and then found out about notificationCompat
|
Mark M. |
in fact, most if not all of the ...Compat classes are in the the android.support.v4 package
|
Mark M. |
Marcin: do you have another question?
|
EGHDK |
But, I'm just saying, how was I supposed to know about notificationCompat
|
EGHDK |
Reading the documentation I guess?
|
Mark M. |
or books written by balding guys :-)
|
EGHDK |
Touche
|
Jan 10 | 4:50 PM |
David O. |
lol
|
EGHDK |
I was just hoping android would be like (Hey! Maybe you wanna use the support compat instead!)
|
EGHDK |
But there's nothing like that, that exists huh?
|
Marcin |
question ab tabs
|
Mark M. |
occasionally they have notes like that, but usually only for stuff they officially deprecated
|
Mark M. |
Marcin: go ahead
|
Marcin |
if i have two tabs A,B... both have two listviews
|
Marcin |
my normal thinking would be that when i click an item
|
EGHDK |
So what would you say are the top three compat imports that people end up using?
|
Marcin |
switch etc etc it behaves like browser
|
Marcin |
so without ability of each tab having a backstack
|
Marcin |
is the proper behaviour that clicking any tab, clears all fragments and presents the listview?
|
Mark M. |
that's impossible to answer in the abstract
|
Marcin |
simple list
|
Marcin |
click item, shows merchant, click item shows detail
|
Marcin |
same for other tab but deals
|
Mark M. |
on a phone-sized screen, launch another activity
|
Jan 10 | 4:55 PM |
Marcin |
for merchant view?
|
Mark M. |
on a tablet-sized screen, reconsider having the tabs in the first place, going with the master-detail pattern instead
|
Mark M. |
for whatever the list item click needs to show
|
Marcin |
any links to this master-detail pattern?
|
Marcin |
or snippets maybe
|
Mark M. |
it's all over the docs, and in the book (in the large-screens chapter and the last tutorial)
|
Marcin |
gr8, thanks for hint
|
EGHDK |
Yeah, master-detail pattern sounds scary, but is really easy. I'm terrible at all this stuff, and I'm able to do it.
|
EGHDK |
hahaha
|
Mark M. |
EGHDK: I have no idea what "the top three compat imports" are, sorry
|
Mark M. |
Aaron: do you have another question?
|
EGHDK |
Mark Murphy. Any opinion?
|
EGHDK |
notifCompat. ActionBarCompat.
|
EGHDK |
theres a fragmentCompat too right?
|
Mark M. |
not by name, but the Android Support package has a backport of fragments
|
Mark M. |
Aaron: do you have another (quick) question?
|
Mark M. |
whoops, I meant David
|
Mark M. |
David: do you have another (quick) question?
|
David O. |
no problem
|
Jan 10 | 5:00 PM |
David O. |
i had something...and i forgot it
|
Mark M. |
OK
|
EGHDK |
See ya mark. I'll be back to bother you on Tuesday.
|
David O. |
well...i guess it will have to wait till tuesday
|
Mark M. |
that's a wrap for today's chat
|
Marcin |
thanks Mark, bye
|
Mark M. |
the transcript will be archived at http://commonsware.com/office-hours/ shortly
|
David O. |
thanks, goodbye
|
Mark M. |
next chat is Tuesday, 7:30pm Eastern
|
Mark M. |
have a pleasant day, all!
|
Marcin | has left the room |
EGHDK | has left the room |
David O. | has left the room |
Mark M. | turned off guest access |