Sep 21 | 7:50 PM |
Mark M. | has entered the room |
Sep 21 | 7:55 PM |
Mark M. | turned on guest access |
Evan | has entered the room |
Mark M. |
howdy, Evan!
|
Evan |
Hey Mark :-)
|
Mark M. |
how can I help you today?
|
Evan |
i'm pulling my hair out trying to get focus to be managed properly in my subclass of AdapterView....
|
Mark M. |
oy
|
Mark M. |
that doesn't sound pleasant
|
Evan |
I'm trying to essentially define for my composite
widget, a hook that will allow me to decide which child to focus. It
will usually seem to decide for me, and my override of requestChildFocus
gets called, but this is too late...
|
Evan |
not sure if I'm phrasing this quite right... but
|
Evan |
is there some callback that i can define that will
allow me to answer the question of which child widget to give focus
when focus propagates down to my composite widget?
|
Sep 21 | 8:00 PM |
Mark M. |
I can tell you that, outside of the focus-related attributes in layout XML, I haven't played with focus stuff at all
|
Chris | has entered the room |
Mike R. | has entered the room |
Evan |
hmm... okay :-/ I've tried overriding ViewGroup's
void requestFocus(int direction, Rect previouslyFocused) but it never
gets called... instead, requestChildFocus gets called.
|
Mike R. |
Hello
|
Mark M. |
are you using addFocusables()?
|
Mark M. |
(btw, howdy, Chris and Mike R!)
|
Chris |
Hi. I have some newbie questions :)
|
Mark M. |
hang on Chris -- I'll get to your question shortly
|
Evan |
i haven't tried that... but calling
setFocusable(true) on the AdapterView doesn't seem to cause my
AdapterView's overridden requestFocus to get called when focus is
propogated down to the widget... (which i would have assumed would be
called before any of hte child widgets were to receive focus)
|
Mark M. |
yeah, focus looks really messy
|
Sep 21 | 8:05 PM |
David | has entered the room |
Mark M. |
you might try to track down the implementation of focusSearch() in the source code and see if that gives you any clues
|
Mark M. |
I'm not quite sure what else to tell you at this juncture
|
Evan |
okay... thanks!
|
Mark M. |
(btw, howdy, David -- you're after Chris and Mike R in the queue)
|
David |
Hi.
|
Mark M. |
Chris: you're turn -- got a question?
|
Mark M. |
er, that's "your turn"...
|
Chris |
My question is in regards to a test program I made
that uses the technique of binding to a service as in Patchy (Android
Tutorials 2.9 chapter 30). I want to be in my main activity and test
whether it is currently bound to a service or not. In IBinder, I found
isBinderAlive() (Check to see if the process that the binder is in is
still alive.). I'm not sure if this is what I should be using, and if
so, I can't figure out how to use it. I think I've found a way around
it, but for a while my app was crashing when I rotated the screen w/o
the service being bound yet because in onDestroy() I had
unbindService(svcConn). I need to read more about the application
lifecycle.
|
Mark M. |
you know if you are bound to a service because of the existence of the IBinder
|
Mark M. |
you use it in onServiceConnected() (e.g., cast to the proper type and store it in a data member)
|
Mark M. |
you drop it in onServiceDisconnected() (e.g., null out the data member)
|
Chris |
Oh OK.
|
Mark M. |
then the question of "am I bound" is "is my data member not null?"
|
Chris |
Yeah. Cool, thanks :)
|
Chris |
Easy one for you.
|
Mark M. |
certainly easier than Evan's focus problem... :-)
|
Mark M. |
OK...Mike, got a question?
|
Evan |
heh... i've been struggling with these for a while.
|
Mike R. |
Got some questions regarding crash reports I've been getting.
|
Mike R. |
First one seems straightforward, but can't seem to see the problem
|
Mike R. |
View paste
|
Mike R. |
that pretty much the whole crash log.
|
Sep 21 | 8:10 PM |
Mark M. |
OK, what does like 183 of Database.java look like?
|
Mark M. |
(er, line 183)
|
Mike R. |
View paste
(6 more lines)
|
Mike R. |
I just can't see where something in here can be null.
|
Mark M. |
which of those is line 183?
|
Mike R. |
Well, the code has been changed since uploading, but I think 183 is the creation of the 'ids' variable
|
Mark M. |
uh, yeah, that hardly seems possible
|
Mike R. |
at any rate, this is the method referenced in the stack trace
|
Mark M. |
for issues like this, using version control and tags will be essential
|
Mark M. |
most likely, db is null
|
Mark M. |
it's about the only thing you're referring to that is not self-contained within the method
|
Mike R. |
Not sure how it could be. this method gets invoked as part of a whole chain of database calls
|
Mike R. |
db gets assigned in the onCreate().
|
Mike R. |
my mistake. it gets assigned in the class constructor.
|
Mark M. |
another conceivable problem would be if SQLException doesn't really support getLocalizedMessage()
|
Mark M. |
oh, wait, no
|
Mark M. |
that would give a NullPointerException inside of Log somewhere
|
Sep 21 | 8:15 PM |
Mark M. |
well, short of you magically coming up with the
version of the method that is in your shipping code, the only thing I
see that could be null is db
|
Mark M. |
even if that seems improbable
|
Mark M. |
but, again, if you want to make sense of
production stack traces, ya gotta keep a copy of the source code that
aligns with the production APK
|
Mike R. |
ok
|
Mark M. |
let me swing back to you in a bit for your next stack trace and let the others have a shot
|
Mark M. |
David: got a question?
|
Mike R. |
you bet
|
Evan |
i've also got another Q when you're ready for me ;-)
|
David |
View paste
|
Mark M. |
well, I don't know much about Drupal
|
Mark M. |
either it has a Web service API that supports the operations you want, or it doesn't
|
Mark M. |
if it does, you'd use it
|
Mark M. |
if it doesn't, you might be able to fake if if
your "parameters like cuisine and dish type" can somehow be converted
into some request that gives you a custom feed or something
|
Mark M. |
and if that's not an option, you'd need to write
an app server to do your queries against the Drupal content store and
return results, and connect your Android app to that
|
Sep 21 | 8:20 PM |
Mark M. |
actually, the "app server" may just be some custom PHP pages
|
Mark M. | |
Mark M. |
but, again, I'm no Drupal expert
|
Mark M. |
David: I'll swing back to you in a bit if you want to follow-up on this
|
Mark M. |
Evan: got another question?
|
Evan |
yes!
|
Evan |
is there a way to wholly not support the landscape orientation and only have "portrait" mode for certain activities?
|
Mark M. |
sure
|
Mark M. |
Step #1: add android:orientation="portrait" to the <activity> element in the manifest
|
Mark M. |
Step #2: probably also add
android:configChanges="keyboardHidden|orientation", to prevent Android
from destroying and recreating the activity for the non-existent
orientation change
|
Mark M. |
that's pretty much it
|
Mark M. |
See the RotationFour example in The Busy Coder's Guide to Android Development
|
Sep 21 | 8:25 PM |
Evan |
and still have it enabled for other activities? (so certain activities are really only portrait- or landscape- specific)?
|
Mark M. |
BTW, you'll need to repeat those two steps for each affected activity
|
Mark M. |
yes, just apply the steps to the activities you want wired to portrait
|
Mark M. |
the others will re-orient as normal
|
Evan |
ah okay, so you define it per-activity...
|
Evan |
thanks!
|
Mark M. |
Chris: got another question?
|
Chris |
OK, my next question is also with Patchy. When we
make a new service connection we send a IPostListener object (listener)
to the PostMonitor service in
"service.registerAccount(prefs.getString("user", null),
prefs.getString("password", null), listener);". Then in PostMonitor
this callback gets assigned to a data member in an Account object. Then
we call this callback and it operates on stuff back in Patchy. So my
question is, when we call this callback from PostMonitor does the
callback have the "context" of which it was defined inside of Patchy and
that's why it can access stuff that was defined in Patchy? Man, I
think I described that horribly, but maybe you get my point.
|
Mark M. |
wow, you type quick
|
Mark M. |
:-)
|
Chris |
haha
|
Mark M. |
the callback is an inner class of Patchy
|
Mark M. |
hence, when we call a method on the callback
object, it has an implicit reference to the outer class (Patchy
activity) and can call methods on it
|
Chris |
OK, that's what I was thinking. Another easy one for you.
|
Mark M. |
that's OK -- I'm delivering training this week, so my brain is tired
|
Mark M. |
Mike: got another question?
|
Mike R. |
yeah. i've got several stack traces that point to onActivityResult. Can't figure out
|
Mike R. |
here's a typical one
|
Mike R. |
View paste
(8 more lines)
|
Sep 21 | 8:30 PM |
Mark M. |
OK, what does ArticlesList.java line 131 look like?
|
Mike R. |
Let me get it out of svn
|
Mike R. |
View paste
|
Mike R. |
line 131 is myAdapter.notifyDataSetChanged();
|
Mark M. |
well, myAdapter must be null
|
Mark M. |
are you explicitly setting it to null anywhere?
|
Mike R. |
no
|
Mark M. |
OK
|
Mark M. |
my best off-the-cuff guess, then, is that it is tied to a configuration change, such as a rotation
|
Mark M. |
I haven't played with startActivityForResult() and orientation changes
|
Mike R. |
i'll look there
|
Mark M. |
if onActivityResult() is invoked after the destroy-and-recreate cycle, that might explain the null adapter
|
Mark M. |
you might need to pass the adapter via
onRetainNonConfigurationInstance(), which worries me some if you're
using the holder pattern
|
Mark M. |
oh, no, nevermind -- holder pattern will be OK
|
Mike R. |
should have been re-created in the recreate cycle
|
Sep 21 | 8:35 PM |
Mark M. |
:: shrug ::
|
Mark M. |
there's no question myAdapter is null, if that's the line that's getting the NullPointerException
|
Mark M. |
I don't have a good way of diagnosing how it could be null, short of random guesses like the rotation one above
|
Mike R. |
i'll try passing it via onRetainNonConfigurationInstance()
|
Mark M. |
I'll try to make a point of testing out onActivityResult() and stuff like orientation changes in the not-too-distant future
|
Evan |
i have another Q when it's my turn...
|
Mike R. |
i'm through
|
Mark M. |
OK
|
Mark M. |
David: got another question, or a follow-up on your first one?
|
Mark M. |
OK...Evan: got another question?
|
Evan |
has anyone been successful in setting up Android
source code in Eclipse so that you can just browse right to the
appropriate framework class while navigating around your own project's
source, and do things like set breakpoints in Android source code? I
think if I can just get this set up so that my debugger will open
android sources, i can get my focus issues figured-out
|
Mark M. |
that is possible, but only if you are running your own custom-compiled firmware
|
Mark M. |
otherwise, the source might not line up, for example
|
Sep 21 | 8:40 PM |
Evan |
i've downloaded the source for the version I'm debugging against... and I've got it set up as a project in eclipse...
|
Evan |
but I'm having trouble figuring out how to get it to treat it as if it were a symbolic representation of the code, you know?
|
Mark M. | |
Mark M. |
even though that is for platform development, that's probably the path you have to run down
|
Evan |
YES!! THat's what I've been looking for!
|
Evan |
thanks, Mark!
|
Mark M. |
get the firmware compiled and running in an emulator, then follow those instructions
|
Mark M. |
OK...Chris: got another question?
|
Chris |
Evan reminded me of something. In Perl I remember
I was able to step through my code and set breakpoints. Is there any
way I can do that with Eclipse?
|
Mark M. |
sure
|
Chris |
I'd like to be able to get to a point and check out the values of variables and such.
|
Mark M. |
AFAIK, it's the same as normal Eclipse development
|
Mark M. |
which, since I don't use Eclipse, I don't know much about
|
Chris |
OK, that's fine.
|
Evan |
yup... check out the Debug perspective...
|
Mark M. |
but Run > Debug should be your starting point
|
Chris |
I'll read up on it.
|
Evan |
if you've got your JDK and everything set up properly, it will just work
|
Evan |
and you can set breakpoints and live-interpret expressions, and so on
|
Evan |
very useful
|
Chris |
Sounds like I'll need to dig into it. I've never used an IDE before.
|
Sep 21 | 8:45 PM |
Chris |
That was my question.
|
Mark M. |
OK
|
Mark M. |
Mike: did you come up with any other questions?
|
Mark M. |
David: you out there?
|
Mark M. |
OK, anyone got another question?
|
Chris |
I have two more queued up when you're ready.
|
Mark M. |
fire away
|
Chris |
Last week I was going to come here and ask a
question about how to keep my service from falling asleep. Then I found
AlarmManager and your WakefulIntenService, which works great btw, in
the tutorials book. I don't understand how the phone can go to sleep
and not handle my service, but it can respond to stuff like
AlarmManager. Do you have any more info on this or point me to the
documentation that describes it?
|
Mark M. |
Simple: AlarmManager relies on some other chip
|
Mark M. |
the main CPU is off
|
Chris |
Cool...
|
Chris |
OK, last one...
|
Mark M. |
however, the "wake up the CPU at such-and-so time" logic is being handled by some other chip
|
Chris |
This is a pretty general question and I'm not sure
what kind of answer I'm expecting, but a general one will probably be
fine. I only have experience writing simple non-OO Perl scripts so
jumping to Java, Android, an IDE is a lot to take in. I think the
biggest obstacle has been trying to get familiar with the Android API.
It's huge. You have any tips on how to get familiar with it? Right
now, I'm just trying to take what I can from your books and make simple
little apps. I think it's working out OK so far, but would like to hear
any suggestions even if it is to just jump in and code.
|
Evan | has left the room |
Mark M. |
well, honestly, if you can spare the time, I'd recommend a few weeks puttering in Java *outside* of Android
|
Sep 21 | 8:50 PM |
Mark M. |
that can give you better Java and Eclipse
experience, because it will line up with more available resources (e.g.,
blogs, online tutorials)
|
Chris |
OK, I got some books. Just need to find some time to work on it.
|
Mark M. | |
Mark M. |
that's a blog post where I list the parts of Java you need for Android
|
Mark M. |
other stuff (e.g., Swing, servlets) aren't really used by Android
|
Chris |
OK, I'm done. I just want to say that I purchased
almost all the Android books and yours is far and away the best. I
once purchased a newly released book at the store and started to work on
some contacts stuff and Eclipse was telling me that it was all
deprecated already :| So I downloaded the latest version of your books
and everything was updated and worked!
|
Chris |
All right. I'll check it out. Thanks a lot!
|
Mark M. |
glad my stuff helps!
|
Mark M. |
anyone else have a question?
|
Sep 21 | 8:55 PM |
Mark M. |
OK, well, we'll wrap the chat for today, then
|
Mark M. |
next one is Thursday, same Bat time, same Bat channel
|
Mark M. |
have a pleasant evening, everyone!
|
Chris | has left the room |
Mike R. | has left the room |
David | has left the room |
Mark M. | turned off guest access |