Office Hours — Today, December 6

Thursday, December 1

Mark M.
has entered the room
Mark M.
turned on guest access
Chaitanya
has entered the room
Chaitanya
Hi Mark, how are you today?
advantej
has entered the room
Mark M.
howdy, Chaitanya and Tej!
advantej
Hey Mark !
Mark M.
Chaitanya: you arrived first -- do you have a question?
Chaitanya
I have a couple of questions
When we publish the app, do all log statements get muted? My concern is about performance and security.
Mark M.
No, all log statements do not get muted
quoting those docs: "Debug logs are compiled in but stripped at runtime. Error, warning and info logs are always kept. "
Dec 6
4:00 PM
Mark M.
I presume that verbose logs are treated the same as debug
however, any work you do to actually do the logging still occurs
again, quoting those docs: "That means that if your log message is filtered out, you might be doing significant work and incurring significant overhead. "
Chaitanya
since debug logs are still compiled, does it impact performace?
Mark M.
the work you do to construct the logged strings, yes
now, if the strings are just static inline "quoted stuff", there should be negligible overhead
and, unless you're doing these in a tight loop, they're not going to cause much impact
Chaitanya
so it is a good practice to strip our application of debug logs before publishing?
Mark M.
um
you can't say that as a blanket statement
if you use a debug logging statement once per year, the extra nanoseconds won't matter
if you use a debug logging statement once per millisecond in a loop, the extra time will matter
now, if you want to take the time to get rid of all of them, more power to you
but I'd be *much* more worried about the error/warning/info (and wtf) logs
and making sure you're not leaking private data in them
Chaitanya
understood. thank you
i'll let advantej ask his question before I move on to my next one
Mark M.
sounds great
Steve B.
has entered the room
Mark M.
Tej: do you have a question?
advantej
Thanks Chaitanya, Hi Mark, my question might sound a bit complex - may be not to you :)
I have extended a DialogPreference. In its onCreateView, I'm returning a custom view which has couple of buttons. On button click, a Facebook signin happens. All is well till here - works fine. On successful login, I get a call back. I need to update the text of this button. Not sure how to go about it.
Mark M.
(btw, howdy, Steve -- we'll get to you shortly!)
Steve B.
(no worries - thanks!)
4:05 PM
Mark M.
hmmm...
I think you need to hold onto the created view yourself
advantej
i tried Activity.runOnUiThread, didn't work
Mark M.
I don't think you can get that back
advantej
what do you mean by hold onto ?
Mark M.
well, let's back up a step or two
user taps your preference
advantej
sure
Mark M.
dialog appears
user clicks button
advantej
yup
Mark M.
you are then... popping up another activity with a WebView?
advantej
kind of
i'm using the FB library
Mark M.
I've never used their library
in part because I don't use FB
advantej
it does all this stuff and finally givs me a callback
into a listener - onComplete method
Mark M.
ah
OK
is the dialog still on the screen at this point?
advantej
yes it is
Mark M.
OK, make the listener be an inner class of the DialogPreference
have the DialogPreference hold onto the View it returns in onCreateView
and the listener in onComplete() updates the TextView
advantej
yup
i can try that..
Mark M.
and I take it that's not working?
advantej
currently i have the listener as a local variable in the onCreateView
Mark M.
that could conceivably work, with the right final keywords
you mentioned runOnUiThread() -- are you being called on a background thread?
4:10 PM
advantej
i'm not sure of that, I just gave it a try since just updating the textview didnt' work
Mark M.
when you say "didn't work", did it crash, or just have no visible effect?
advantej
no visible effect,
Mark M.
that's a little odd
advantej
if i go somewhere and comeback, i see the text changed
this simple text update is killing me for 2 days now
Mark M.
"go somewhere" meaning close the dialog and reopen it?
advantej
actually its not a pop up dialog, i have used your Pref/Fragments example
Mark M.
well, DialogPreference uses a dialog
that's kinda why they named it that way :)
advantej
so the "Dialog" appears on the right side Fragment
Mark M.
why am I thinking that DialogPreferences still pop up dialogs?
yes, DialogPreferences pop up dialogs
4:15 PM
Mark M.
in my sample, the RingtonePreference, EditTextPreference, and ListPreference are all subclasses of DialogPreference
advantej
ok. in the Pref/Fragments, the preference_headers points to a fragment... and this fragments creates a CustomPreference(extends DialogPref) and adds the view.
Mark M.
and that View appears in a dialog
advantej
it appears not as a pop up but in the right fragment
Mark M.
um, not in any of my testing
even a custom DialogPreference, like the TimePreference from the tutorials, brings up a dialog when you tap on it
oh, wait
onCreateView()
advantej
yes
!
Mark M.
I was thinking onCreateDialogView()
I still don't know why that would not update
there are samples around (albeit not in my books) of updating the text inside a Preference dynamically
advantej
Hmm.. let me try the innerclass thingy and hope for the best
and will try to find other examples as well
Mark M.
4:20 PM
Mark M.
that second one suggests perhaps calling getListView().invalidateViews() in your PreferenceActivity (or, in your case, PreferenceFragment, I guess)
anyway, give that stuff a shot and hopefully it'll help
Steve: do you have a question?
advantej
sure.. thanks !
Steve B.
Yes sir. My question is about MapViews. I can annotate them, place overlays on current location, etc. I'm curious - what's the proper way to enable a "tap & hold" type of gesture? I tried setLongClickable and passing in a listener, but it never seems to fire.
(Ideally I'd like to translate the tap & hold point to obtain the lat/long and then perform reverse geocode on it)
Mark M.
if I had to guess, you will have to handle that yourself using onTouchEvent()
others have asked that, and it appears that MapView does not support setOnLongClickListener()
for whatever reason
the Advanced Android book has a sample of doing drag-and-drop of OverlayItems that uses touch events
Steve B.
Pardon my ignorance, but by onTouchEvent, do you mean something like a GestureDetector?
Mark M.
no, though conceivably that could work too
haven't tried GestureDetector for long-clicks
onTouchEvent() is a method you override
4:25 PM
Mark M.
that's the project associated with the drag-and-drop example in the Advanced Android book
4:25 PM
Mark M.
the ItemizedOverlay implements onTouchEvent()
you get a MotionEvent as a parameter
it will tell you things like ACTION_DOWN, meaning the user placed a finger on the screen
and so on
my example, and the accompanying prose in the book, explains how to use that to detect a tap on an OverlayItem and arrange to drag-and-drop that OverlayItem
in your case, you would detect a down event, and if there is no corresponding up event within X milliseconds, it's a long-click
and you do something
Steve B.
Yes - I recall NooYawkTouch. I'll give that another look. Thank you!
Mark M.
sure!
Chaitanya: you said you had another question?
Chaitanya
Yes
I apologize if this is a basic question, but I'm still learning how to effectively code in Java and use the Android SDK
Its about creating menus: all of the activities in my app have menu items. some are common, some are not. what is the most efficient way to code this?
such that I dont recreate ALL menu items in EACH activity
Mark M.
um, well, to a large extent, you don't have a ton of choices
Chaitanya
but rather each activity can specify which items it needs
4:30 PM
Mark M.
you're welcome to cook up some sort of MenuDelegate, to which your activities pass your onCreateOptionsMenu(), onOptionsItemSelected(), etc. events
along with flags indicating what they want
and have the MenuDelegate handle that work
or, use inheritance
depending on the nature of your app, when you move into fragments, the fragments can also contribute to the options menu
zettie
has entered the room
Mark M.
in which case, it may be that simply having the right fragments on-screen magically gives you the right menu choices
Julius
has entered the room
Julius
(Howdy)
Mark M.
but outside of that, there's nothing particularly unique to Android here -- just choose a pattern (e.g., composition and delegation) that you like
(btw, howdy, zettie and Julius -- be with you momentarily!)
Chaitanya
sorry but I didn't understand any of the suggested solutions
by delegation
Mark M.
to be honest, your simplest solution is: just duplicate the code for now
Chaitanya
do you mean extension? Like activity extends menuActivity ?
Mark M.
that would be inheritance
Chaitanya
ok
Mark M.
you could create some sort of ChaitanyaBaseActivity that has your common menu logic
and have other activities inherit from it
since Java does not support multiple inheritance, you can run into problems here
Chaitanya
wouldn't that imply all menu items will be inherited?
Mark M.
you would have to have smarts in ChaitanyaBaseActivity to determine what is needed for each specific subclass
4:35 PM
Chaitanya
how can the baseActivity know which activity its being used in?
Mark M.
it would call an abstract method that the subclasses would override
or, ChaitanyaBaseActivity would only handle the common ones, and subclasses would override the same methods (e.g., onCreateOptionsMenu()) and add in the activity-specific ones
again, none of this is unique to Android
this is all Java and object-oriented programming
Chaitanya
ok, it looks like I need to spend some more time understanding some of the concepts you've brought up
Mark M.
let me get to some of the other folks' questions, and I can perhaps swing back to you for more in a bit
zettie: do you have a question?
Chaitanya
thank you
zettie
How do I ensure data security in an android app? Is it enough if I post to a https link that I've been told is secure?
Mark M.
um, I could easily do a day-long seminar on "how do I ensure data security in an android app"
and really it would need to be a week-long class, but I probably don't know enough to fill that time :)
HTTPS on Android is not significantly different that HTTPS anywhere else
done right, it solves the problem of people intercepting the data between you and the server
4:40 PM
zettie
is the "done right" on the web server side or the app side?
Mark M.
ideally, the Web server uses an SSL certificate from a well-known certificate authority, that Android will recognize
if, for some reason, the Web server will use some other SSL certificate (e.g., a self-signed one), that may require additional work on the app side to ensure that it is a valid certificate
Julius: do you have a question?
Julius
yes:)
View paste
I was wondering if anyone might know how to put in delimiters in the ActionBar as shown in this question: http://stackoverflow.com/questions/7189385/how-to-add-a-separator-between-menu-items-in-actionbar
sorry bout that not sure why my paste went like this
advantej
has left the room
Julius
hmmm I just realised that I haven't looked this up in your latest book (apologies if it's in there, feel free to just tell me and I'll go look it up)
Mark M.
not sure
Julius
I was hoping for some kind of flag or something
it seems like it's used quite abit
Mark M.
there's probably a style or theme setting that controls that
zettie
ok. thanks.
Julius
ah that rabbit hole :)
thanks all the same
Mark M.
sorry!
Steve: do you have another question?
Julius
appreciate your itme
time
4:45 PM
Mark M.
OK, does anybody have another question?
Julius
well...
:)
do you know if there is a place to go to see how the styles are implemented
sort of like a reverse lookup
Mark M.
that depends on what you mean by "the styles"
for the SDK, they're in your SDK itself
$SDK/platforms/$API/data/res/values
Julius
so if I see something I want to change flip through some images to find the piece which I'm wanting to override
Mark M.
if you mean for an AOSP app, they'd be in the repository
Julius
yeah that's like a "forward" lookup
zettie
hey, I foolishly did not check your books for anything on android data security - is there anything written on it?
Mark M.
but for closed-source apps like Gmail, not really
Julius
I guess the problem is I don't always know what the style is referring to
Mark M.
zettie: there is no single spot for security
zettie: it is covered in various places related to the tech (e.g., files)
zettie
lol. ok thanks
Mark M.
zettie: nothing on HTTPS, since it's pretty much standard Java
zettie
I will do some searching. thank you!
Mark M.
Julius: yeah, I know what you mean
Julius
I find I am overriding some piece of style and I end up guessing a bit
could be my lack of skills with Themes and styles
Mark M.
if you only have to guess "a bit", you're better at it than I am
Julius
hahahah
(always a pleasure)
Mark M.
I feel that I usually am just swinging a sledgehammer and seeing what breaks when I fuss with styles
Julius
yeah... ok so it's not just me
I might try bring it up a hangout
at at ^
at a
4:50 PM
Steve B.
has left the room
Mark M.
any other questions from anyone?
zettie
has left the room
4:55 PM
Chaitanya
has left the room
Julius
you likely to try to get to IO again?
Mark M.
oh, probably
Julius
cool well if we both manage to get tickets I'll try catch up again
it'll be a lottery this time so, not sure if I'll make it
Mark M.
did they officially state it'll be a lottery?
Julius
(I hope so though - we converted out Android dev group into a GTUg earlier in the year)
but I don't think that will help us
Mark M.
GTUGs should get help if you wanted to host the streaming events
Julius
umm my understanding is that there will be some programming questions to weed out non developers as they want to aim it at developers
Mark M.
but I don't know about actual tickets
oh, well, now, that should be interesting
Julius
I think after that you go into a lottery of sorts
but I'm not sure
don't hold me to it!
5:00 PM
Julius
I think they wiull also have some tickets available for a coding competition too
Mark M.
well, anything's an improvement over let's-all-sign-up-at-once-and-crash-the-server
yeah, they did that last year too
Julius
so to actually complete the registration you have to complete programming questions
Mark M.
for a lot of people, the streaming will suffice
Julius
ah I didn't know
yeah that's true
the time difference isn't too big here
Mark M.
they gave away 100 tickets or so through some coding challenges, months after the server collapse
Julius
if I suddenly feel super wealthy (unlikely) I'd contemplate setting up a local streaming setup
Mark M.
anyway, that's a wrap for today's chat
Julius
yeah
oops 111 I better let you go
yeah
thank you again
Mark M.
next one is tomorrow at 7:30pm US Eastern
Julius
have a good day / evening
Mark M.
have a pleasant day, all!
Julius
cool
bfn
Julius
has left the room
Mark M.
turned off guest access

Thursday, December 1

 

Office Hours

People in this transcript

  • advantej
  • Chaitanya
  • Julius
  • Mark Murphy
  • Steve Baranski
  • zettie