Mar 31 | 7:25 PM |
Mark M. | has entered the room |
Mark M. | turned on guest access |
Steve S. | has entered the room |
Mark M. |
hello, Steve!
|
Mark M. |
how can I help you today?
|
Steve S. |
Hi Mark!
|
Steve S. |
I have a question regarding the activity lifecycle. I'll upload it.
|
Steve S. |
View paste
|
Mar 31 | 7:30 PM |
Mark M. |
well, I can't speak for those example authors
|
Steve S. |
Sure
|
Mark M. |
and, since I know both diddly and squat about the Bluetooth APIs, I cannot speak specifically about whether what they're doing makes sense for that
|
Steve S. |
What would you recommend?
|
Steve S. |
ok
|
Mark M. |
the only scenarios that I know of when onDestroy() will not be called are:
|
Mark M. |
1. if the process is terminated with extreme prejudice (e.g., Force Stop)
|
Mark M. |
2. you crash with an unhandled exception
|
Mark M. |
and, that's pretty much it
|
Mark M. |
*usually*, onDestroy() gets called
|
Mark M. |
*when* it gets called is another matter
|
Steve S. |
ok
|
Mark M. |
it might be quite some time, depending on a variety of environmental factors (amount of system RAM, how busy the other apps are, etc.)
|
Mark M. |
and so anything you delay cleaning up until onDestroy() may be active for a while
|
Mark M. |
that could be a good thing or a bad thing, depending on circumstances
|
Mark M. |
usually, I consider it to be a bad thing
|
Mark M. |
as probably either you should be cleaning it up sooner or you should be having a service manage whatever it is
|
Mark M. |
but, there's no hard-and-fast rule for this
|
Moe | has entered the room |
Steve S. |
This is helpful.
|
Mark M. |
OK, good, because I wasn't sure if it was useful or not for your inquiry
|
Mar 31 | 7:35 PM |
Mark M. |
let me take a question from Moe, and I'll be back with you shortly
|
Steve S. |
So it sounds like if onDestroyed() isn't called, the system wold be messed up enough anyway that it wouldn't matter.
|
Mark M. |
Moe: hi! do you have a question?
|
Moe |
hi mark
|
Steve S. |
sure, thanks
|
Moe |
yeah, something to do with Android Studio
|
Moe |
Hi Steve
|
Moe |
o here is the error I'm getting
|
Steve S. |
hi moe
|
Moe |
View paste
|
Moe |
I removed one of these files, but then it complains that the file is needed
|
Moe |
removed the other, same thing
|
Moe |
this seems to be a question better suited for Stackoverflow
|
Mark M. |
um, are these official ANTLR artifacts?
|
Mark M. |
I haven't used ANTLR in years
|
Moe |
but thought you've might faced something similar
|
Moe |
honestly Mark I have no idea, but I suspect one of the libraries I've added
|
Moe |
because things were going OK before I added few libraries
|
Moe |
including Realm
|
Mark M. |
oh, you're not requesting these as dependencies yourself directly?
|
Moe |
no
|
Mark M. |
you can use the Gradle dependency report to track down who is pulling those in: https://docs.gradle.org/current/userguide/tutor...
|
Mark M. |
(fortunately, I had the direct link handy!)
|
Moe |
Ok, thanks
|
Moe |
I also see these warnings
|
Moe |
View paste
|
Moe |
But they don't seem to prevent the build
|
Mar 31 | 7:40 PM |
Mark M. |
no, but they may cause other problems
|
Mark M. |
make sure that whatever is pulling this stuff in is set up to work on Android
|
Moe |
mostly are everyday stuff
|
Mark M. |
it may be that you're pulling in some library that was designed for ordinary Java, that may or may not be working on Android
|
Moe |
Retrofit, OKHttp and the likes
|
Moe |
will look again into them
|
Mark M. |
I'm sure Square isn't pulling that stuff in, though I can't rule out Realm
|
Moe |
yeah, things started with Realm
|
Moe |
here is what I'm using
|
Moe |
View paste
|
Mark M. |
wait
|
Mark M. |
realm-gradle-plugin probably doesn't go there
|
Mark M. |
Gradle plugins go in the dependencies closure inside the buildscript closure, in the top-level build.gradle file
|
Moe |
I moved it from there for some reason, but this seems like a good start
|
Mark M. |
double-check the Realm docs to see where that goes
|
Moe |
will start investigating here first
|
Moe |
Ok, thanks Mark
|
Mark M. |
everything else, as you say, seems fairly normal
|
Mark M. |
let me take a question from Steve, and I'll be back with you in a bit
|
Mark M. |
Steve: your turn! do you have another question?
|
Moe |
I try to keep this way
|
Moe |
Ok, thanks
|
Mar 31 | 7:45 PM |
Moe |
that's it for me today, have a great evening guys
|
Steve S. |
Getting back to my earlier question: it sounds like if onDestroyed() isn't called, that would be because things are so messed up that it wouldn't matter. Is that right?
|
Mark M. |
well, either the process is gone (in which case, you probably don't care about whatever didn't get cleaned up), or you crashed (in which case, you have bigger problems)
|
Steve S. |
Great, that helps.
|
Steve S. |
Here's another question:
|
Steve S. |
View paste
|
Mark M. |
I haven't seen code use setListAdapter(null)
|
Mark M. |
it might be part of a "hey, let's help the GC engine out" effort
|
Steve S. |
I see. So there's no reason to do that.
|
Mark M. |
none that I am aware of
|
Mark M. |
if the ListView gets destroyed, its reference to the adapter should be let go
|
Steve S. |
Thank you. That's very helpful.
|
Mark M. |
now, it could be that there's something goofy with ListFragment that I'm not aware of, where calling setListAdapter(null) has benefit
|
Steve S. |
ok
|
Mark M. |
but I haven't encountered it
|
Mark M. |
it's also a cheap call, so if you want to do it, for a "belt-and-suspenders" sort of thing, go right ahead
|
Steve S. |
Great. I won't worry about doing that.
|
Mark M. |
personally, I'd wait until I had concrete evidence of a memory leak, like a LeakCanary singing
|
Mar 31 | 7:50 PM |
Mark M. |
let me take another question from Moe, and I'll be with you again shortly
|
Steve S. |
I don't have any more questions today. Thank you so much for your help! Have a great evening, Mark.
|
Mark M. |
Moe: your turn! do you have another question?
|
Mark M. |
(Steve: you too!)
|
Steve S. | has left the room |
Mar 31 | 8:00 PM |
Moe | has left the room |
Mar 31 | 8:25 PM |
Mark M. | turned off guest access |