Office Hours — Today, May 25

Thursday, May 20

May 25
7:55 PM
Mark M.
has entered the room
Mark M.
turned on guest access
Mike R.
has entered the room
Mike R.
Hi Mark
Mark M.
howdy, Mike!
Mike R.
some questions about the soft keyboard
Mark M.
ok
Mike R.
i have a couple of edittext fields and would like to have a little better control over what goes on in the app with them
for instance, i'd like to know when the user has started typing into them
Mark M.
that may not be easy
Mike R.
i've registered an onKey listener but that doesn't work with regular keys
8:00 PM
Mike R.
is there some way to programmatically dismiss the keyboard?
Mark M.
yes...hold on...
There is hideSoftInputWindow() on InputMethodManager
however, I don't know where to get the IBinder first parameter
oh, sorry -- hideSoftInputFromWindow()
Mike R.
how do I get an inputmethodmanager?
Mark M.
it's a system service -- getSystemService()
Mike R.
is this covered in any of the books?
Mark M.
no
in part, I don't recommend doing it
Mike R.
why
Mark M.
1. spontaneously causing the soft keyboard to go away will piss off users
2. preventing people without hardware keyboards from typing will piss off users
whatever your business problem is, hopefully there is another solution
Mike R.
it's not spontaneous. it would happen when they press a button and a process starts.
Mark M.
oh, sorry, I thought you were trying to get rid of the keyboard once they started typing, per your first comment
8:05 PM
Mike R.
no. 2 different problems
Mark M.
they should use the action button, then -- lower right corner
ah, here we are
View paste
		InputMethodManager imm=(InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);

		imm.hideSoftInputFromWindow(search.getWindowToken(), 0);
(where search is an EditText)
run that when they click the search button
(assuming this is search -- whatever button it is you are worried about)
you can also have the action button rigged for search:
View paste
	<EditText android:id="@+id/search_field"
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content"
		android:layout_alignParentTop="true"
		android:inputType="text"
		android:imeActionId="1337"
		android:imeOptions="actionSearch"
		android:hint="@string/search_hint"
  />
Mike R.
does this permanently hide the keyboard? do I need to do something to re-enable it?
Mark M.
see the android:imeActionId and android:imeOptions attributes
no, this dismisses the current invocation of the keyboard
it'll come back automatically on the next EditText
Mike R.
that should work then.
Mark M.
you can use setOnEditorActionListener() to find out when they press the action button
Mike R.
ok
back to my original question. Let me state the broader objective.
there are 2 edittext fields and a button on the window
8:10 PM
Mike R.
i only want the button to be enabled if there are values in both the edit text fields
so, the broader question is, what event can I use to trigger a test of the edit text fields and (possibly) enable the button?
Mark M.
I do not know of a good way to do that
setKeyListener() does not work well with soft keyboards
Mike R.
that's < good
Mark M.
a total hack is to poll the fields every second via postDelayed()
if you know of some activity in Android itself that has this feature, I can try to figure out how they pull it off
Mike R.
i think i'll just leave the button enabled and ignore any presses until the fields have values
just doesn't seem like a great user experience.
8:15 PM
Mike R.
would putting up a toast be appropriate in this situation?
Mark M.
possibly
it wouldn't cause any true harm
might be distracting
you could try addTextChangedListener()
supply a TextWatcher where your afterTextChanged() sees if the fields are empty
since this isn't tied to "keys", it may work with soft keyboards -- haven't tried it
Mike R.
where do i find the definition of addTextChangeListener?
Mark M.
that is on TextView
8:20 PM
Mike R.
thanks. found it. i think i'll give that a try.
well, getting close. may have an app before too long.
bye bye for now.
Mark M.
see ya!
Mike R.
has left the room
8:40 PM
Robert C.
has entered the room
Mark M.
howdy, Robert!
Robert C.
hi
Am I really the only one here
Mark M.
right now, yes
somebody was here earlier
Robert C.
cool
A coworker named Casey said he met you at Google I/O
I'm working for TuneWiki. I bought your books so I could get up to speed on the platform quickly.
Mark M.
cool!
Robert C.
I haven't gotten through all of them yet. About half way through the first one.
Do you know if WMA codec is available for Android?
Mark M.
it's licensable by handset makers
not open source
most phones appear to have it, but not all will
Robert C.
I saw it costs about $800k or something about that.
How would I find it on the phones?
Mark M.
yeah, I haven't heard of a price tag
look up their spec sheets online
Robert C.
For example, Nexus One?
Mark M.
doesn't look like it
8:45 PM
Robert C.
I went here. Is this right?
8:45 PM
Robert C.
8:45 PM
Mark M.
not terribly shocking
8:45 PM
Mark M.
yes
WMA isn't in the audio decoders list
Robert C.
I saw that RadioTime was able to play WMA which got me curious.
Ok, I see that now.
I do see AAC, AAC+ though which is nice.
Just to pat you on the back, I like what you have done in supporting Android. Books, chat, mailing lists, etc. Looks like it is working for you.
Mark M.
it keeps me busy
Robert C.
that is good, right?
Mark M.
yes, it's a good sort of busy :-)
Robert C.
Is there a code way to detect what decoders are available?
Mark M.
not that I'm aware of
I have gone looking for it from time to time
seems like an obvious thing, but I haven't run across it yet
a fine question to pose on StackOverflow
Robert C.
I figure it is a C code thing.
Good idea though to use SO.
Mark M.
oh, I'm sure OpenCORE and StageFright know what
er, what's possible
I just don't see where it's surfaced in the SDK
8:50 PM
Robert C.
I guess over time and lots of requests it will get there.
Well, I don't have too many other questions right now. Once I get through the books and get deeper into the platform I'm sure to have some.
I'd probably hit the forum unless I had some deeper questions.
Mark M.
I try to hold these twice a week, though at different times of the day to cover more geography
StackOverflow is an awesome Android resource right now
better signal-to-noise ratio than the Google Groups
even get the occasional real live Googler
:-)
Robert C.
I'll keep that in mind.
Not sure about the Googler though. :)
Mark M.
just tag your question with 'android'
(sans quotes)
Robert C.
Just looked at DROID.
Here is the audio list.
AMR-NB/WB, MP3, WAV, AAC, AAC+, eAAC+, WMA
Mark M.
right
Motorola has seemed to license WMA across the board
HTC has for all I can think of other than the Nexus One
Robert C.
Sounds good to me. I'll have to get one of their phones and give it a try.
Mark M.
not sure about Samsung, Sony Ericsson, LG, etc.
Robert C.
Is there a one stop page for comparing what all the phones have?
8:55 PM
Mark M.
since there are ~60 phones, not that I'm aware of
Robert C.
Maybe I'll put one together since I need to know who supports what codecs.
Mark M.
might make a good spreadsheet
Robert C.
I think so. I'll need the data anyway. If I make it, I'll link back to ya.
Mark M.
the chat period is coming to a close -- any other questions?
Robert C.
Nope. I think I have my work cut out for a while.
Thanks for the help and keep up the good work.
Mark M.
thanks!
Robert C.
ttyl
Mark M.
c-ya
Robert C.
has left the room
Mark M.
turned off guest access

Thursday, May 20

 

Office Hours

People in this transcript

  • Mark Murphy
  • Mike Renda
  • Robert Casto