Office Hours — Today, December 20

Thursday, December 15

Dec 20
7:25 PM
Mark M.
has entered the room
Mark M.
turned on guest access
Alex B.
has entered the room
Alex B.
Hi Mark
Mark M.
howdy, Alex!
how can I help you today?
Alex B.
so I'm working on this app with multiple activities
now I want to create a sort of parent navigation activity which keeps track of state mostly, but also has some convenience methods
7:30 PM
Mark M.
what do you mean by "parent"?
Alex B.
what's the best strategy to do that?
Mark M.
do you mean a superclass?
Alex B.
yea
but the problem is my superclass would have to inherit off Activity
Mark M.
correct
or whatever other base class you are presently using (e.g., FragmentActivity)
Alex B.
and if I want to use a MapActivity, I can't use that superclass
Mark M.
correct
Alex B.
which is a problem since I want to use both fragments and maps :)
Mark M.
that is not presently possible, if you are using the Android Support package
leastways, you can't put a MapView in a fragment
Alex B.
I am using the support package
Mark M.
because MapActivity does not inherit from FragmentActivity
Alex B.
I understand that, they would be different activities
Charlie
has entered the room
Mark M.
then you probably do not want to "create a sort of parent navigation activity"
Alex B.
which is why I'm here
Mark M.
use composition instead of inheritance
(BTW, howdy, Charlie!)
Alex B.
for example I'm listening for screen off events
Charlie
Hi. First time here.
Alex B.
in all my activities
and creating the same menu in all my activities
Mark M.
put those hunks of code in static methods, then
where you pass in an Activity as a parameter
you would still need to override onPrepareOptionsMenu(), etc. in the activities
and you might elect to create a thin base Activity class that handles those overrides
7:35 PM
Mark M.
but, by putting most of the logic elsewhere, copying those handful of callback methods into your MapActivity will not be as big of a deal
Alex B.
I see
Mark M.
and, while you're doing all of this, wish that the core Android team had chosen Ruby instead of Java :-)
Alex B.
ruby has multiple inheritance?
Mark M.
Ruby has mixins
gives you much of the effect of multiple inheritance
Alex B.
interesting, never got that deep into ruby
Mark M.
fun language
it's what I use when I'm not doing Android stuff
let's swing over to Charlie
Charlie: do you have a question?
Alex B.
sure
Charlie
Have the need to enter time information into a form in mm:ss format
Boils down to TextWatcher vs. some sort of time picker
The time will be entered into a form that is part of an alert dialog. Any issues with launching another dialog like a time picker from that?
Mark M.
I've never tried it, and it would scare the heck out of me
why the AlertDialog in the first place?
7:40 PM
Charlie
The app puts together a list of songs. I looked into launching another activity for a new song ( ala NotePad demo) vs. using a dialog to enter the song info.
Mark M.
generally speaking, avoid dialogs
they limit the user's flexibility in navigation
the more complex the thing in the dialog, the less likely it is that it should be in a dialog in the first place
Charlie
good point.
Mark M.
heck, even the name/value dialog in my ConstantsBrowser sample, with two whole fields, is a bit more than I'd ordinarily do
Charlie
See the dialogs alot with tablets though.
Changing to a full screen activity might be too much.
Then there's fragments...
Mark M.
with tablets, using a dialog suggests an underlying navigation issue
I agree that popping a whole 'nuther activity would be overkill
Charlie
I played around with TextWatcher a bit for the number entry.
7:45 PM
Charlie
Are you familiar with the PhoneNumberFormattingTextWatcher?
Mark M.
not particularly
I'm allergic to long class names :-)
Alex B.
then you must love objective-c heh
Mark M.
never touch the stuff
there's a language that should have died back in the mid 1990's
anyway, I take it you want to create an MinutesSecondsFormattingTextWatcher?
Charlie
It allows user to enter a phone number and automatically puts in dashes
I was going to modify it to use for mm:ss time entry but it might be more confusing for the user.
View paste
There is a Windows Phone app that I was able to test this approach on and  it can lead to inconsistent results.
Mark M.
if you are going to stick with the dialog for the form, and you don't have room for a pair of NumberPicker widgets, your TextWatcher is about the best you can do
if you switch away from the dialog to an activity, rolling a MinutesSecondsPicker, based on TimePicker, should be doable
but I'd be nervous about popping a dialog from a dialog
Charlie
Yes, it seems to work in the quick hack but I'm concerned other issues might creep up.
7:50 PM
Mark M.
issues tend to do that
wish we could tie bells on 'em
Charlie
I'm thinking of using the DateSlider widget
Mark M.
that's sexy
not sure how easy it would be to modif
er, modify
Charlie
Its got what I need.
But has one annoying quirk. Both wheels turn
Mark M.
OK
Alex B.
another question, I was making a widget for google tv devices, for the preferences activity, I'd like to use the built in preference stuff, but how do I "save" them if I use a preference activity
Mark M.
Alex: PreferenceActivity automatically persists preference changes
Alex B.
so the only way for users to exit that is to press back
Mark M.
to exit a PreferenceActivity, the user presses BACK, or HOME, etc.
Alex B.
so for an update frequency preference (update every x minutes) I was using a text edit box for testing
7:55 PM
Mark M.
you mean an EditTextPreference?
or your own activity with an EditText?
Alex B.
is there a page though the google docs which shows all the possible preference types?
my own activity with an edit text
Mark M.
look at the JavaDocs for android.preference.Preference
and look at the subclasses
Alex B.
I was wondering about a visual index, to see how they look as well :)
Mark M.
oh
not that I am aware of
Alex B.
they should make something like that, the way they did for the "hello views" page
Mark M.
they don't even really maintain "hello views" all that well
Alex B.
that's true
Mark M.
it's certainly a need, but I wouldn't hold my breath
Alex B.
so what do you think of the google tv?
Charlie
The same app I'm discussing re: time picker will need have the capability to reorder a list of songs. Then save the reorder in database.
Mark M.
Charlie: TouchListView could handle that
Alex: I watch so little TV, that the notion of running apps on a TV just isn't a use case for me personally
professionally, it's intriguing, and I have a chapter coming out on it in a week or two
Charlie
Yes. But concerned about how to update the database. There is a stackoverflow question about this that I need to dig into.
Alex B.
ah nice
which book is it going to be in?
8:00 PM
Charlie
Paul Carf from Google is speaking about Google TV at a meetup here in CA tomorrow.
Mark M.
Charlie: I'm assuming your database has some sort of sequence number column that you would need to update, in a bunch of UPDATE statements, in a tranasction
Alex: The Busy Coder's Guide to Advanced Android Development
Alex B.
makes sense
yea, I wish they'd put more of the talks videos online
like the ones from AndDevCon ||
Charlie
Mark I think you suggested two approaches to the touchlistview database issue. Trying to find the question on stackoverflow.
Mark M.
it's possible -- I don't remember the question, and, well, I've answered enough that finding a specific one of mine is a wee bit challenging
Charlie
I think one of the suggestions was using an array and doing the sort there before updating the db
Mark M.
oh
8:05 PM
Mark M.
TouchListView needs a mutable adapter, like an ArrayAdapter on an ArrayList
so, you can't really use it directly with a CursorAdapter
the two approaches were:
1. schlep the data from the Cursor into an ArrayList and use an ArrayAdapter
2. create a ReorderingCursorAdapter that maintains its own internal sequence information and maps everything from list positions to their corresponding current positions in the Cursor
the plus side of #2 is that it would be faster at runtime and generate less garbage
Charlie
Option 1 sounds easier
Mark M.
the minus side of #2 is that #1 is easier :-)
Charlie
The list that needs to be sorted won't be too long, about 10 to 15 items
Mark M.
that won't take long to convert into an ArrayList, then
Alex B.
Mark are the chat logs for the office hours available online?
Charlie
Thanks for the additional info. I'll dive into the list sorting after I get the time picker worked out.
Mark M.
Alex: I email a link to the transcript to the cw-android Google Group, for any chat with a meaningful transcript
8:10 PM
Mark M.
I don't have an RSS/Atom feed for them at this time
nor a centralized archive page
as I am laaaaaaaaaaaaaaaaaaaaaaazy
Alex B.
ok
heh, I thought campfire might offer that sort of functionality
Mark M.
not publicly visible
I can see them
but I don't see where I can make that something that anyone can access
though it's been ages since I looked, so I'll check again
Alex B.
I remember I searched for something on google once and it took me to a chat transcript of one of your office hours
Charlie
Alex, that's rare
Alex B.
yea, I wish I'd have saved it
Charlie
I rarely get hits on the google group. Stack Overflow usually dominates the search results
Alex B.
well that's all for me tonight guys
have a good one
Mark M.
see ya!
Charlie
What are your thoughts on NFC's adoption in US?
Alex B.
has left the room
Mark M.
well, the NFC, having won the last two Super Bowls, is fairly popular
oh, no, wait
you aren't talking about football
Charlie
Yes, probably again this year
no.
Mark M.
right now, there are too few devices
8:15 PM
Charlie
I attended the WIMA conference in san franscisco earlier this month
8:15 PM
Mark M.
including precisely zero from a certain fruit-flavored device category
Charlie
The head of the NFC forum had the same joke!
Mark M.
heh
even if 100% of new Android phones shipped with NFC, it would take a long time for critical mass to be achieved
and 100% of new Android phones will not have NFC, as I understand it
so, it's the sort of thing that has interesting long-term potential
Charlie
Yes, the 2 year contracts on the phones slows things down.
Hard to tell if the indie developer will have a shot at a piece of the pie.
Mark M.
which pie?
Charlie
all the potential revenues from NFC
the banks will get all the payment $
Mark M.
:: shrug ::
Charlie
Developers may have a shot at non-payment revenue.
Mark M.
that's like asking who is getting all the potential revenues from cameras
Charlie
Have you tested NFC with more than one NFC app on your phone?
Mark M.
yes
had a couple of existing NFC apps plus my one sample
haven't done a ton with it outside of the sample, but I don't know where I'd encounter an NFC tag
Charlie
It kind defeats the no tap that google touts
Mark M.
now that my Nexus S has the ICS upgrade, I need to play around with Android Beam
Charlie
You have to select which app to read the tag. Which results in a tap
How did you get ICS on the Nexus S?
Mark M.
OTA update happened... yesterday? day before?
8:20 PM
Mark M.
regarding the tag and taps, that depends on how you set up the tag and filters
preference is given to more specific matches
Charlie
I haven't turned mine on in a few days. Thanks for the heads up.
Mark M.
yeah, I don't know how the OTA rollout is happening
Charlie
So I may be able to disable another app and pick the one that I want to read?
Mark M.
also, mine is a T-Mo Nexus S, not a Sprint one, and I think that matters
not so much "disable" as "have a tag that targets your app better"
for example, take a tag with a URL encoded on it of http://commonsware.com/nfctest
an app that says "I handle NFC tags where the URL is http://commonsware.com/nfctest"; will be invoked with no chooser
even though other apps on there say "I handle NFC tags that have anything on them"
Charlie
Great. Thats what I was hoping for.
Mark M.
so, I think it is a matter of choosing a tag structure and <intent-filter> combination that works right
Charlie
I have the NXP app and a couple of others installed that all come up in the chooser.
Mark M.
for example, a tag with a vCard should pop all apps that are NFC-aware and deal with contacts, but not arbitrary NFC stuff
right
again, it depends a bit on the tag and the <intent-filter>
over time, we'll work out all the rules and patterns to follow
Charlie
Ok. Thanks for the great info. Have to get rolling now. happy holidays.
Mark M.
you too!
Charlie
has left the room
8:30 PM
Mark M.
turned off guest access

Thursday, December 15

 

Office Hours

People in this transcript

  • Alex B.
  • Charlie
  • Mark Murphy