Office Hours — Today, April 29

Tuesday, April 27

Apr 29
9:25 AM
Mark M.
has entered the room
Mark M.
turned on guest access
9:30 AM
Justin M.
has entered the room
Justin M.
Hi there Mark, good morning!
Mark M.
howdy, Justin!
Ron B.
has entered the room
Mark M.
howdy, Ron!
Ron B.
Hello.
Justin M.
Hi there, nice to get a chance to talk with you! Just my luck I checked your office hour schedule and saw they were this morning, the timing was perfect! Hopefully I have a quick question with an easy answer
Mark M.
I like those :-)
Ron B.
I have a couple of questions, I'll start after Justin.
Jake B.
has entered the room
Justin M.
So, I have a ListActivity, and I'm trying to disable the default selector bar that's generated when using the d-pad/trackball...
Mike Q.
has entered the room
Mark M.
Justin: listSelector="#00000000", right?
Justin M.
I can disable it for touch events by using the android:listSelector="#00000000" attribute for the ListView in the layout.xml, but it still seems to be active for d-pad/trackball
Mark M.
it shouldn't be
Justin M.
View paste
I looked at the selector set in /data/res/drawable/list_selector_background.xml: <item android:state_focused="true"
        android:drawable="@drawable/list_selector_background_focus" />
Mark M.
Sebastian
has entered the room
Jake B.
Hey Mark, you answered my question about TabActivity with options menus on Stack Overflow yesterday ( http://stackoverflow.com/questions/2707448… ). I came up with a workaround that has fixed it for me so far, and neither me nor my coworker can see any obvious potential gotchas with it. Could I run the solution by you, just to make sure there are no potential problems (obvious potential for crashes or inconsistent behavior) that we're missing?
Justin M.
And I tried overriding that in a custom selector that I created, but it seems to have no effect
Mark M.
Jake: wait!
Jake B.
sorry
Mark M.
Jake: I'll get to your question in turn, please hold on
9:35 AM
Justin M.
Wondering if it might be a bug that it's not being recognized?
Mark M.
Justin: I linked to a sample project from the Advanced Android book that demonstrates using a custom selector by disabling the regular selector
Justin M.
I see the link there, is there someplace in there specific that I should look? I think I was looking at it yesterday actually
Mark M.
AFAIK, that works with the D-pad, as that's the only way to actually test it
there's not all that much to the code
just having android:listSelector="#00000000" on the ListView should suffice
try building that project as-is -- if it works, steal some ideas; if it fails, let me know
('cause then I have some work to do...)
Justin M.
OK, interesting. I just saw that when I tried it, listSelector="#00000000" disabled it for touch events, but the dpad/trackball movements still have that red bar. Well, good to know that I'm not crazy at least! OK, I'll try your project and get back with you by e-mail then. Thanks for the sanity check! :-)
I'm good for now
Mark M.
OK, next to sign on was Ron
Ron: do you have a question?
Ron B.
I am trying to develop a mechanism to provide application updates. The model is that it is an internal distribution. What type of coding constructs do I need? Am I copying a file from the server to a location on the Droid? What location?
Mark M.
any location, AFAIK
you may need to ensure the file is world-readable, though
you can then start an activity that will initiate the install process
9:40 AM
Ron B.
OK, I guess I'm having trouble with the concept, where am I writing to?
Mark M.
SD card or your app-local file store (getFilesDir())
Ron B.
Right now I developed on Eclipse and downloaded. I want the update to go to the same place.
Mark M.
Huh?
Ron B.
I want to replace the application with the one stored on the server.
Mark M.
the installation process itself handles that
you don't need to worry about it
you just need to get the APK file onto the device
Ron B.
Do you have a code sample?
Mark M.
of downloading a file?
hc.apache.org has samples for HttpClient
a whole bunch of Web sites have examples for using URL and HttpUrlConnection
you can also see a download in the Service/WeatherPlus sample app
writing a file from the downloaded data is just standard Java file I/O
this code should work for triggering the install of the downloaded APK: http://android.amberfog.com/?p=98
9:45 AM
Mark M.
(BTW, Service/WeatherPlus is from my original Android book -- http://github.com/commonsguy/cw-android/tr…)
Ron B.
OK, I'll run with that for now. Thanks!! Do I requeue for my next question?
Mark M.
yes, please
Jake: you're up now
Jake B.
View paste
First of all, sorry for jumping ahead there; I'm used to IRC, didn't realize the format :)

Anyways, as I described on StackOverflow ( http://stackoverflow.com/questions/2707448/strange-options-menu-behavior-in-android-tabactivity ), we have a TabActivity whose tabs are populated with Activities (rather than Views). Each tab, when loaded, starts up its own AsyncTask, then populates its own list once the task finishes. If we switch around through tabs really quickly (while their AsyncTasks are still running), we're able to get it into a state on a certain tab where the wrong options menu will load (as in, the one for a different tab).

On StackOverflow, you told me that using Activities as the contents of tabs causes a lot of bad stuff, and that it's better to use Views. We'll definitely follow this route in the future and restructure, but we have a major deadline very quickly, and don't have time for a restructuring like that before then.

In the meantime, we came up with a workaround. I've got the important bits of the code here: http://gist.github.com/383619

Basically, each activity implements that interface and does all its menu work in afterPrepareOptionsMenu. It feels like a 
...
oops, didnt realize it would cut off
Basically, each activity implements that interface and does all its menu work in afterPrepareOptionsMenu. It feels like a gross workaround, but so far, it's fixed the problem for us. Do you see any potential problems (obvious potential for crashes or inconsistent behavior) that we're missing?
Mark M.
yeah, pasting has its issues...
Sebastian
has left the room
Jake B.
sorry about that :)
Mark M.
not your fault -- Campfire is a bit strange
it is not clear where you're getting optionsMenuTargetId from
but the general approach of manually delegating menu creation to the right tab should be OK
Jake B.
I'm getting it from onTabChanged
Mark M.
ah, I see
Jake B.
Yeah, we had tried that originally by just using TabActivity.getCurrentActivity, but that was getting equally confused
Mark M.
and that's probably what was triggering your menu problems in the first place
might be a bug in Android
9:50 AM
Mark M.
but, if this system is functionally working for you, I don't see huge problems with it
Jake B.
Great, I really appreciate it. Just wanted to make sure there were no big obvious problems we were missing.
Mark M.
other than my general reservation against activities-in-tabs
Jake B.
Awesome, thanks so much :)
Mark M.
and sorry for squashing you earlier, but there's only one of me, and I am a Bear of Very Little Brains, so I can't handle too many things at once
next up is Mike
Jake B.
No worries :)
Mark M.
Mike: do you have a question?
Mike Q.
Hi Mark, can a menuitem register a context menu so I can do a long press on one of the menu items?
Mark M.
no
Menu is an abstraction
while there may be Views under the covers, you don't have access to them
Mike Q.
Well, that was easy huh?
Mark M.
for me, yes
for you, perhaps not so much :-)
Mike Q.
Well that's really all I had. it is a bummer though!
Mark M.
OK, with Sebastian gone, that completes the first pass
Justin: did you have another question?
Ron: I believe you had another question?
Ron B.
Yes thanks! I'm trying to mute Text message arrival sounds but not call ringing sounds? Is this possible?
9:55 AM
Mark M.
beats me
I haven't played around in that area of Android yet
If a user can do it through the Settings application, you could look at the code, see how they do it, and see if that's possible for an ordinary SDK app
Ron B.
Maybe it's a vocabulary issue. I see "Notification Sounds" discussed as well as "Ringer Volume". Does the former refer to SMS and the latter to calls?
Mark M.
hold on, I actually don't have a phone right here
yeah, I'm not sure
I'm over 40, so I'm not a big SMS guy :-)
the latter is definitely calls
Ron B.
Me too! Sometimes the vocabulary is harder than the actual concept.
Thanks anyway.
Mark M.
the Ringer Volume has a checkbox to control whether it manages both ringtone and "notification volume"
my guess is that they treat all notification sounds the same way, whether SMS or other ones (e.g., SD card mount/unmount)
10:00 AM
Mark M.
anyone have another question?
Mike Q.
Actually, I do have another. Any thoughts on how to keep error logs on the device and having a way to access them through a menu item?
Mark M.
Usually, the approach is to send error information over a series of tubes back to some central server (e.g., Flurry, DroidDrop)
you really want something in addition on-device?
Mike Q.
Do you have any examples anywhere on that being done?
That would be preferable to on-device.
Mark M.
well, I haven't published any samples myself, but Flurry has some, and I think DroidDrop had usage instructions as well
there are others -- those are the two names that stick in my head
If you want the whole LogCat, rather than just your exceptions, look for Android Log Collector
I think they're hosted on code.google.com
Mike Q.
Ok, I will check those out. i was unaware they existed.
Will check that out too. Thanks.
Mark M.
I wrote a blog post about 'em late last year on AndroidGuys
10:05 AM
Mike Q.
Great. Thanks again.
Mark M.
ah!
anyone else have a question?
Ron B.
Well, if no one else is speaking. Is there a way to get an actual address from a GPS lat/long. Is the Droid GPS accurate enough for this anyway?
Mark M.
by "actual address", do you mean building, street, city, etc.?
Ron B.
Street number, so that a snail mail could be sent if needed.
Mark M.
sorta
you'll get an "array of Addresses" to choose from
assuming it has the info
there are third party services for this as well, I think, that you can access via Web services
10:10 AM
Ron B.
Thanks, that's what I was looking for. I live in 1/3 acre zoning and my Droid GPS with a third party lookup said I was about 3 houses away. I'll try to see if I show up on the "list". Thanks!!
Mark M.
anyone else have a question?
Justin M.
Think you also answered another unasked question I had with that, thanks :-)
Jake B.
Mark: Is there any simple way of just straight up clearing the entire history behind your activity? We've seen various things with CLEAR_TOP, but they all seem to have some gotchas.
Mark M.
I've tried to avoid navigation patterns requiring those sorts of shenanigans
10:15 AM
Jake B.
We have too, but there are a few places where we can't see an alternative (for example, we don't want people to tap "Log out", and then back into the activity they were just in (which requires credentials)
Mark M.
what problems have you had with CLEAR_TOP?
Jake B.
i can't remember off the top of my head, it was a long time ago. i just figured id run it by you real quick if you didn't have any other questions. if there's nothing off the top of your head, we're handling the problem in an acceptable way currently, so no worries.
Mark M.
yeah, sorry
Jake B.
no problem
Justin M.
Mark, how often do you have office hours?
Mark M.
usually one or two a week
depends on my travel schedule
10:20 AM
Mark M.
so, next week, there will only be one
Justin M.
OK, cool deal, and did I see that you do custom on-site training too?
Mark M.
absolutely!
Justin M.
Might have something for you, I'll email you about it :-)
Mark M.
sounds good, thanks!
any other questions?
10:25 AM
Mike Q.
has left the room
Jake B.
None from me, thank you so much for the help; I really appreciate it.
Mark M.
happy to help!
Ron B.
Thanks Mark, over and out.
Ron B.
has left the room
Mark M.
well, that's a wrap for today's chat
10:30 AM
Mark M.
have a pleasant day!
Justin M.
has left the room
Jake B.
has left the room
Mark M.
turned off guest access

Tuesday, April 27

 

Office Hours

People in this transcript

  • Jake Boxer
  • Justin Munger
  • Mark Murphy
  • Mike Q
  • Ron Bruckman
  • Sebastian