Office Hours — Today, April 28

Tuesday, April 26

Mark M.
has entered the room
Mark M.
turned on guest access
Apr 28
7:30 PM
David
has entered the room
Mark M.
howdy, David!
David
Hi Mark,
Mark M.
how can I help you today?
David
View paste
touch image_A adds image_B to another scrollView
When image_B is touched, the same method onClick is called.
When image_B is called, I want activity start. How can I differentiate these two images on OnClick?
Mark M.
um, use different methods
7:35 PM
Mark M.
or listeners
7:35 PM
Mark M.
are you creating image_B in Java code?
David
load from drawable.
Mark M.
another possibility is to look at the View that is passed into your onClick method
OK, let's back up a step
image_B is not "load from drawable", because Drawable objects do not respond to clicks. ImageView does, Button does, other widgets do
Mike R.
has entered the room
Mark M.
Are image_A and image_B being displayed by two separate ImageView widgets?
(btw, howdy, Mike R!)
Mike R.
Hello
David
Yes. the image_B is added to ImageView, then addView is called.
Mark M.
right
so, you have two choices:
David
onClick, I checked the instance of ImageView.
Mark M.
1. You use a different OnClickListener object for the second ImageView
2. You examine the View that is passed into onClick() and see which ImageView it is
fitz
has entered the room
fitz
MORNING (somewhere right...)
David
Image_A and B added different scrollView.
Mark M.
howdy fitz!
David: that does not matter
David
I see. I will try what you suggested.
Mark M.
OK
Mike: do you have a question?
7:40 PM
Mike R.
Yes.
In my app, I have an object that contains a lot of State information.
I periodically serialize all of the object within the state information
All the objects implement Serializable
at app startup I de-serialize my object(s) and I'm good to go
If the de-serialization throws an exception, I no that this is a new install and I initialize all of my state objects.
this works great - 99.99 percent of the time
Every once in a while, the de-serialzation runs without an exception, but the objects that are returned are all null
this is a bad thing. what can I do to prevent it?
Mark M.
use something other than serialization?
I've never liked Serializable
painful to debug and slow
I assume that you haven't caught this in the lab?
Mike R.
Isn't this what Serializable was made for?
I caught it once
but I've gotten several crash logs from Android Market, so it's happening in the wild
7:45 PM
Mark M.
the question is, where's the problem coming: is the file corrupt when it is being written, or is the read hiccuping on a good file?
Mike R.
Also, it happens on the device and I don't think I can actually look at files on the device. Can I?
Mark M.
no, but you can copy the file to SD, or upload it somewhere
in terms of "isn't this what Serializable was made for", I'd write the data to XML, JSON, or SQLite well before I'd fart around with some proprietary opaque format
Mike R.
I think it's happening on the write, because once it starts happening it happens every time on startup - rendering the app unusable.
Mark M.
hmmmm...
not sure what to tell you
I suggest doing a bit more protection at write time
Mike R.
what kind of protection can i do?
Mark M.
serialize to a temp file, read it back in to make sure it's good, then get rid of the real file and rename
basically, don't assume your write worked until you test it
BTW, are there any patterns in terms of what devices are having this problem?
Mike R.
I haven't looked at the crash logs in detail. I know it happened on my Droid
Mark M.
OK, it's not an ext4 issue, then
7:50 PM
Mark M.
Mike R.
One thing that I was doing it Serializing in the OnDestroy() method of the last Activity
Took that out of the code recently
I'm thinking maybe the app was getting killed before the serialzation was complete
Mark M.
that's certainly a possibility
Shawn V.
has entered the room
Shawn V.
Hi
Mark M.
anyway, let me take some other questions, and I'll cycle back to you in a bit
Mike R.
ok
Mark M.
fitz: do you have a question?
(btw, howdy, Shawn!)
fitz
yes - but on phone so will wait
Mark M.
ok
Shawn: do you have a question?
Shawn V.
Yes,
I have been doing Android for 8 months
But embedded software for about 20 years
I am supporting a software package written by BNR
So I have a lot of good examples to go by
But there are some fundamental ideas I think I am missing
For example, a view has a concept of an emptyView
But does it have a concept of an error view or multiple error views
I can always pop a dialog or update a text view
7:55 PM
Mark M.
first, a View does not have a concept of an emptyView
AdapterView does
so, ListView, GridView, etc.
second, no, there is nothing like an "error view"
UI handling of errors is up to you
scottt
has entered the room
Shawn V.
Another?
Mark M.
let me swing through the others, and I'll get back with you in a bit
Shawn V.
Sure
Mark M.
scottt: nice timing -- do you have a question?
scottt
not yet. ph call
Mark M.
OK
David: do you have another question?
Mike: do you have another question?
Mike R.
Nope. Still thinking about dealing with the first one.
Mark M.
OK
fitz: you ready?
8:00 PM
scottt
i don't have a question, but a comment: you're mentioned in 2 new books i just rec'd
p120 of Beginning Android Games and p445 of pro Android 3
Mark M.
heh, both Apress
Shawn: got another question?
Shawn V.
Definitely
Mike R.
has left the room
Shawn V.
I have an app that has two tabs and a view in each tab
On view uses and GroupedObjectCursorAdapter->ObjectCursorAdapter-BaseAdapter
scottt
yeah. a little cross-marketing, eh? BAG directs the reader to yout books for more info on layouts/view groups/etc
Shawn V.
The other is based on an ArrayAdapter
Now, I was asked if I could combine these two views into one scrollable view
And I thought of using the mergeAdapter you talked about
But in learning to think Android
I just wanted to know if there is any way to bind two views
Into a parentView that can scroll up and down
I know I said that like a 4 year old
Mark M.
yes and no
there is ScrollView
but you cannot put scrollable things, like a ListView, in a ScrollView
they fight over the touch events
8:05 PM
Shawn V.
That makes sense
And from a user perspective I think it is a bad idea,
But I have iPhone developers blazing the UI trail before me
So they think of some wacky things they want to do with the UI
Mark M.
that's a large part of the reason why MergeAdapter exists -- so you can stitch two Adapters' worth of data into one scrollable entity
Shawn V.
My understanding thought is that the merge items are sort of treated the same way?
though
Mark M.
treated the same as... what?
Shawn V.
Once the items are merged, can you implement separate onClickListeners for each item type?
So that items come from one source have one type of listener
Mark M.
no
the listeners are by the ListView
you will need to distinguish type from type yourself based on position
fitz
Mark I did look in detail at Adv Ch 17, 18, 19 - have some great ideas and might even see light at the end of the LONGGGGG tunnel - so thanks for books - keep on updating them :)
Shawn V.
That makes sense. Thansk.
Mark M.
fitz: hopefully, it's not an oncoming truck
scottt: do you have a question?
fitz
are you going to JAX this year in San Jose - guess first your in US
Mark M.
fitz: no, not going to JAX
8:10 PM
Mark M.
either the conference or the city in Florida
8:10 PM
fitz
na it is an ambulance
8:10 PM
fitz
ok - got a free ticket the other day so thinking about it
scottt
Pro Android 3 mentions your WakefulIntentService and gives the github link
fitz
I have question on books - will hit you up on next office session - need to deal with phone issues again
scottt
but i need to get back to the BCG2AAD so that i can try to acquire more bug bounty codes to give out as door prizes
Mark M.
fitz: OK, two next week, 2:30pm Eastern
fitz
ok thanks cya
fitz
has left the room
Mark M.
scottt: that's all cool... but do you have a question?
scottt
i did, but all-nighter made me forget it :-(
Mark M.
oops
sorry
maybe you'll remember before the chat ends
OK, free for all -- anyone with a question, chime in
Shawn V.
I have a book question. I have your books and several others and at a medium to low level, they are very good, give good examples, etc
But is there a book, documentation, etc at a very high level
8:15 PM
Shawn V.
That helps you see the Object Patterns in Android that helps you in visualizing
Mark M.
I don't really know what "a very high level" is with respect to Android
there's not that much in the way of "object patterns in Android"
IMHO
Shawn V.
I guess like a Patterns book for Android
More about problem solving in the Android environment
Mark M.
usually patterns books come out several years after the introduction of a technology
Shawn V.
And the "correct" way to go about certain things
Mark M.
check back in 2013 or 2014 :-)
Shawn V.
:)
Mark M.
"correct" varies over time
Shawn V.
Plus my background is varied, but mostly from a very low level.
Mark M.
I'll be getting into bits and pieces of that in _Tuning Android Applications_, the next book in the series
Shawn V.
This is the first time anyone has been brave enough to let me touch a UI :)
Awesome!
Mark M.
but that'll be mostly along the lines of patterns for saving CPU/battery/RAM
not "high level"
Shawn V.
I just got a 50 page white paper from the "mobility experts" where I work on that kind of stuff
scottt
i'd recommend some of the slides from some of the conventions
Mark M.
yeah, conference presentations are often good for high level depictions
Google I|O sessions are all on YouTube
Shawn V.
I have watched several of the Google I/O 2009 and 2010 and they were very helpful.
scottt
View paste
check out the work-sessions from www.google.com/events/io/2010/sessions.html
Mark M.
a bunch of the Android ones from this year's should be streamed live
Shawn V.
I'm just kind of hard-headed. Too many years of being able to do anything I want in C code
Yeah, I heard that. People asked me if they stream them live, why go?
Mark M.
that's a fine question
Shawn V.
I always thought you went to those things to have fun and talk to people about the stuff you do
scottt
perhaps to get the handout phone?
Mark M.
there are some benefits to being there live
8:20 PM
Shawn V.
Very few people I know that I can talk Android development with
And the iPhone people really don't get me :)
Mark M.
scottt: yeah, I suspect that's why I|O sold out in less than an hour
scottt
i find conventions very motivational -- especially on someone else's dime
Mark M.
conversely, outside of I|O, I pretty much avoid conferences unless I'm presenting
too many people
scottt
look for an android dev group near you. i just started one here in tampa bay to have others to share info/etc with
Shawn V.
I went to one last week that started here in Tampa, Fl
scottt
i found google's group listings paltry and frankly pathetic, but meetups.com has a lot of groups for a lot of things
oh. did i meet you there?
Shawn V.
Yep
scottt
lol!
Shawn V.
So I tried to do a really bad thing in Android last week
Mark M.
I'd cue up "It's a Small World", but that's more Orlando... :-)
Shawn V.
I tried to implement a dialog inside of a listener and make the listener return the results of the dialog
scottt
did you just join commonsware? i was plugging it.
Shawn V.
Really bad idea.
Are there any really common bad ideas people have when writing Android Apps?
scottt
(you're welcome mark. but its not entirely unselfish of me to make sure your site/books stay around)
Mark M.
Shawn: all UI stuff in Android is asynchronous, so, yeah, your approach was pretty much doomed
8:25 PM
Mark M.
scottt: thanks for the kudos!
Shawn V.
Scott: I took a class from BNR and as part of the class I got a year's subscription
Yep, I did a face plant when I realized what I was trying to do.
scottt
i'm trying to get our site set up for apress's user group program, but nobody answers my emails to their contact
Mark M.
Apress has a user group program?
Shawn V.
Are there any other ones that you see people trying to do over and over again Mark?
Mark M.
they're not terribly well organized
Shawn: lots, but everlasting services is probably one of the biggest bugaboos
scottt
they say they do (on their home page), but its been a couple/few weeks and a couple of emails and no response yet
i'll try calling the ph# next
Shawn V.
Everlasting services?
Mark M.
ones that you start and never stop, particularly starting them at boot time
99.99% of Android apps do not need them
Shawn V.
Nope, the app I work on has a service that starts when the application starts
Mark M.
they're the reason the task killer was invented
Shawn V.
But it is mostly for being able to download content after the user has selected it when they aren't using the app
Mark M.
so long as you shut that service down as soon as you're done with it, you're good
ah
OK, so long as it shuts itself down when it's out of work (e.g., IntentService), you're good
Shawn V.
That is the case.
Nothing in queue, the service shuts down
scottt
i mistyped earlier, it was the work sessions for this link that had a lot of android-101 info: http://andevcon.com/speakerpresentations.html
Shawn V.
I didn't code it though, I just use it
Mark M.
beautiful!
scottt
the sessions at the end of the list that sart with W-
Shawn V.
Thanks Scott
8:30 PM
Mark M.
yeah, AnDevCon had some decent sessions
David
has left the room
scottt
i banged out a quick-and-dirty app the other night to solve an immediate need
Shawn V.
We'll it's 8:30. Back to making tiny green cashy pieces of paper for writing code for the evil Very Large Telecom Company (VLTC)
scottt
i needed a quick way to send a clock-in/out type email
Shawn V.
Thank you very much for having this service and writing your books
Mark M.
happy to help!
Shawn V.
Next office hours?
scottt
cya guys
Shawn V.
Never mind, I see it now
Good night all and thanks again
scottt
mark, look me up when you come to tampa bay. i'll buy you a beverage of your choice
Mark M.
2:30pm Eastern Tuesday and Thursday next week
scottt: ok!
have a pleasant day, all!
scottt
has left the room
Shawn V.
has left the room
Mark M.
turned off guest access

Tuesday, April 26

 

Office Hours

People in this transcript

  • David
  • fitz
  • Mark Murphy
  • Mike Renda
  • scottt
  • Shawn Vines