Apr 19 | 8:55 AM |
Mark M. | has entered the room |
Mark M. | turned on guest access |
Apr 19 | 9:05 AM |
Ken B. | has entered the room |
Mark M. |
hello, Ken!
|
Mark M. |
how can I help you today?
|
Ken B. |
Good morning.
|
Ken B. |
I have a bunch of diffuse questions, and some specific ones.
|
Ken B. |
First:
|
Ken B. |
Android comes with a lot of prebuilt styles and styles intended for themes and R.id things and so on
|
Ken B. |
But I can't find any coherent, single description of these items. Am I looking in the wrong places?
|
Mark M. |
you would have to look in some parallel universe, where this stuff is concisely documented
|
Ken B. |
That's conforting.
|
Ken B. |
comforting
|
Mark M. |
usually, people find the concept of parallel universes to be anything but comforting
|
Ken B. |
So, randomly searching around StackOverflow is the best bet?
|
Ken B. |
the concept relieves us of all moral responsibility.
|
Ken B. |
Let's not talk about moral philosophy.
|
Mark M. |
hunting around to see what others have done with their experiments with these themes and styles is one approach
|
Apr 19 | 9:10 AM |
Mark M. |
you can also see what Google uses them for
|
Ken B. |
by looking at google sources?
|
Mark M. | |
Ken B. |
ha
|
Mark M. |
yes
|
Ken B. |
okay, I'll try.
|
Mark M. |
the Opersys search engine helps, as you can find references to various strings and symbols
|
Ken B. |
What is Opersys search engine?
|
Mark M. |
the link that I posted a bit ago in the chat: http://xref.opersys.com/
|
Ken B. |
Oh, on that site.
|
Mark M. |
yes, you choose your Android version, and you get a somewhat convoluted search form
|
Ken B. |
I have spent weeks refining a dumb project that uses searchview, but I am unhappy with ti.
|
Ken B. |
First, take a look at this:
|
Ken B. |
View paste
(133 more lines)
|
Ken B. |
It is a searchable that is engineered to be its own searchable as well, in order to allow the user to refine his query.
|
Ken B. |
First, is that a reasonable strategy?
|
Mark M. |
I haven't tried that
|
Mark M. |
on the whole, I've been underwhelmed by Android's search framework
|
Apr 19 | 9:15 AM |
Mark M. |
I haven't worked with it seriously in ~5 years
|
Mark M. |
which is why I yanked my chapter on it, as that chapter was stale
|
Ken B. |
Is there another strategy for refining a search that is more common.
|
Mark M. |
I'll hopefully have time to try it again in the future
|
Mark M. |
I can't really answer that
|
Ken B. |
In trying to figure it out, I rewrote the Android tutorial doc for searchview in English. You are welcome to it.
|
Mark M. |
sounds like a great post for your blog, if you have one
|
Ken B. |
No blog.
|
Ken B. |
Have you any experience with launchmode singletop
|
Mark M. |
a bit
|
Mark M. |
on the whole, I try to avoid fussing with launchMode
|
Mark M. |
for exported activities, sometimes it is unavoidable
|
Ken B. |
what is an exported activity
|
Mark M. |
one with an <intent-filter>
|
Mark M. |
i.e., one that a third-party app can start
|
Ken B. |
ok
|
Apr 19 | 9:20 AM |
Ken B. |
I am confused about onSaveInstanceState/ onRestore*
|
Ken B. |
It seems that onSave.* is called at various times in the cycle, depending on the weather or the phase of the moon. Is that observation valid?
|
Mark M. |
it is called around the time of onPause()/onStop(), in cases where the activity is not being immediately destroyed
|
Ken B. |
For example, sometimes it is called just after onCreate (and before the onCreateMenu) which makes it hard to save the state if part of the state is created there.
|
Mark M. |
I have never seen that
|
Ken B. |
hm.
|
Ken B. |
I may be hallucinating.
|
Mark M. |
if you come up with a sample app that can reproduce the behavior, shoot me a link, and I can take a peek at it
|
Ken B. |
Easy to do after too many hours at the terminal.
|
Ken B. |
It's this one.
|
Ken B. |
See where I am testing searchView = null in onsave instance state
|
Mark M. |
yes
|
Mark M. |
it'
|
Apr 19 | 9:25 AM |
Mark M. |
it's possible that launchMode is somehow triggering this behavior
|
Ken B. |
that is because it is called before oncreateoppitons menu
|
Mark M. |
though I'm not aware that it would be
|
Mark M. |
you're also using AppCompatActivity, which I generally avoid
|
Ken B. |
I used it becasue google asked me to.
|
Ken B. |
Next.
|
Mark M. |
BTW, ot'
|
Ken B. |
huh?
|
Mark M. |
BTW, it's not completely out of the question for onSaveInstanceState() to perhaps be called before onCreateOptionsMenu(), but there would have to be some specific reason for it (e.g., configuration change)
|
Ken B. |
That would be quick work for the wrist, to force a configuration change before the app menu appears.
|
Mark M. |
so, your defensive programming might be needed
|
Mark M. |
agreed
|
Mark M. |
statistically, it is improbable
|
Mark M. |
and so if you're seeing it repeatedly, it's likely stemming from something else
|
Ken B. |
The books say that the state of views that have id's are saved.
|
Ken B. |
automaticall, on config change.
|
Mark M. |
for user-mutable state, yes
|
Ken B. |
but that doesn't seem to hold for the contents of the textedit in searchview.
|
Ken B. |
So I have to save it myself here.
|
Ken B. |
Am I doing right?
|
Mark M. |
most likely
|
Mark M. |
I seem to recall running into this too
|
Ken B. |
assuming, of course, I want to save a partially entere query on state change.
|
Apr 19 | 9:30 AM |
Mark M. |
let's rephrase it as "well-written widgets will save their user-mutable state automatically"
|
Apr 19 | 9:30 AM |
Mark M. |
SearchView may be screwing up the state management
|
Ken B. |
so this is not an hallucination.
|
Mark M. |
I don't think so
|
Mark M. |
OTOH, you could be hallucinating this chat
|
Ken B. |
Which relieves you of all moral responsibility for it.
|
Mark M. |
you were hallucinating the moral responsibility, too
|
Ken B. |
Now, there are two paths into onNewIntent
|
Ken B. |
Both are from searchview, one from a text query and the over from a spoken query
|
Ken B. |
See onNewItent.
|
Mark M. |
I don't completely grok the "a searchview in a different activity requests a search on second and subsequent calls" comment
|
Ken B. |
You would think that forwarding the query would remove focus from the query widget. Which is true for text, but not for voice.
|
Apr 19 | 9:35 AM |
Ken B. |
I am thinking ahead. I am supposing that this thing can be invoked as a searchable from a separate activity.
|
Ken B. |
In that case, the activity will be created, and onCreate will be called rather than onNewIntent.
|
Ken B. |
Once the thing exists, calls go through onNewIntent.
|
Mark M. |
that assumes the thing exists
|
Mark M. |
if you have some nav option that keeps this activity around yet lets you go back to some outside activity, OK
|
Ken B. |
right.
|
Mark M. |
but if, say, the user presses BACK from this activity, it's destroyed, and the separate activity would wind up creating a new instance of this activity on a future search
|
Ken B. |
So that complication doesnt' exist.
|
Ken B. |
Things are not as bad as they seem. Only nearly so.
|
Mark M. |
but, with regards to the difference in focus behavior, I can't explain that
|
Mark M. |
if anything, I would have expected the inverse behavior (text would keep the focus, voice would not)
|
Apr 19 | 9:40 AM |
Ken B. |
I am concerned about all this complicated logic I need to save and restore state.
|
Ken B. |
It seems klugy.
|
Ken B. |
is it typical?
|
Ken B. |
Is there a clean way to do it ?
|
Mark M. |
"typical" varies by app, but what you have is not unreasonable
|
Mark M. |
assuming that it's all necessary, which I'm not really in position to comment upon
|
Ken B. |
that, I guess, was my question. Whether I was way off base.
|
Ken B. |
I have tested it all to try and eliminate some of it, and it is all necessary.
|
Mark M. |
in terms of "clean", cleanliness, like beauty, lies in the eye of the beholder
|
Apr 19 | 9:45 AM |
Ken B. |
The logic is there just to preserve the status quo ante. When the user changes configuration, I want show the same state he started with. It just doesn't seem good that it takes so much logic to do "nothing".
|
Mark M. |
ah, but this isn't just for configuration changes
|
Ken B. |
what else/
|
Ken B. | |
Mark M. |
while that may be the more common scenario, it's also for when your process gets terminated but the user returns to your app's recent task fairly quickly (e.g., within a half-hour)
|
Mark M. |
in that case, Android is going to try to return the user to the app in the state in which they left it, versus coming through the front door of the launcher activity
|
Mark M. |
and so, your new activity in your new process gets your saved instance state
|
Mark M. |
this is why Bundle is limited into what it can store -- that data has to be able to be passed across process boundaries
|
Ken B. |
by terminated, you mean he hits the back button, or home button?
|
Mark M. |
user is in your app, then navigates to another app (HOME, incoming call, you launch the other app, recent-tasks list, whatever)
|
Mark M. |
when your app is not in the foreground, your process can be terminated at any point
|
Ken B. |
Because, I think when I hit the back button then restart, I don't get a Bundle.
|
Ken B. |
Okay.
|
Apr 19 | 9:50 AM |
Ken B. |
I am surprised and chagrined that the Google documentation is so raggedy ass. I gues they expect you to read the source, like a real person.
|
Mark M. |
the docs vary in quality
|
Mark M. |
and, Android is vast
|
Mark M. |
but yes, it would be nice if they spent more time on the docs
|
Mark M. |
when some balding guy in eastern PA can write about as much as Google does about Android, there's a problem
|
Ken B. |
True. But if some of these writers were working on my product (and a bunch did) they would have learned a thing or two by now.
|
Mark M. |
oh, I don't doubt that Google has the knowledge and experience
|
Mark M. |
what they lack is people writing the documentation
|
Ken B. |
Okay, I am going to have to let you go. I can't think of anything else right now. But I'll be back.
|
Mark M. |
OK
|
Mark M. |
the next office hours chat is tomorrow, 4pm US Eastern
|
Apr 19 | 9:55 AM |
Ken B. |
Adios
|
Ken B. | has left the room |
Apr 19 | 10:00 AM |
Mark M. | turned off guest access |