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
|
Chaitanya |
My first is about Log usage: http://developer.android.com/reference/and…
|
Chaitanya |
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
|
Mark M. |
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
|
Mark M. |
however, any work you do to actually do the logging still occurs
|
Mark M. |
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
|
Mark M. |
now, if the strings are just static inline "quoted stuff", there should be negligible overhead
|
Mark M. |
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
|
Mark M. |
you can't say that as a blanket statement
|
Mark M. |
if you use a debug logging statement once per year, the extra nanoseconds won't matter
|
Mark M. |
if you use a debug logging statement once per millisecond in a loop, the extra time will matter
|
Mark M. |
now, if you want to take the time to get rid of all of them, more power to you
|
Mark M. |
but I'd be *much* more worried about the error/warning/info (and wtf) logs
|
Mark M. |
and making sure you're not leaking private data in them
|
Chaitanya |
understood. thank you
|
Chaitanya |
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 :)
|
advantej |
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!)
|
Dec 6 | 4:05 PM |
Mark M. |
hmmm...
|
Mark M. |
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
|
Mark M. |
user taps your preference
|
advantej |
sure
|
Mark M. |
dialog appears
|
Mark M. |
user clicks button
|
advantej |
yup
|
Mark M. |
you are then... popping up another activity with a WebView?
|
advantej |
kind of
|
advantej |
i'm using the FB library
|
Mark M. |
I've never used their library
|
Mark M. |
in part because I don't use FB
|
advantej |
it does all this stuff and finally givs me a callback
|
advantej |
into a listener - onComplete method
|
Mark M. |
ah
|
Mark M. |
OK
|
Mark M. |
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
|
Mark M. |
have the DialogPreference hold onto the View it returns in onCreateView
|
Mark M. |
and the listener in onComplete() updates the TextView
|
advantej |
yup
|
advantej |
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
|
Mark M. |
you mentioned runOnUiThread() -- are you being called on a background thread?
|
Dec 6 | 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
|
advantej |
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
|
Mark M. |
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?
|
Mark M. |
yes, DialogPreferences pop up dialogs
|
Dec 6 | 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
|
Mark M. |
even a custom DialogPreference, like the TimePreference from the tutorials, brings up a dialog when you tap on it
|
Mark M. |
oh, wait
|
Mark M. |
onCreateView()
|
advantej |
yes
|
advantej |
!
|
Mark M. |
I was thinking onCreateDialogView()
|
Mark M. |
I still don't know why that would not update
|
Mark M. |
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
|
advantej |
and will try to find other examples as well
|
Mark M. | |
Dec 6 | 4:20 PM |
Mark M. | |
Mark M. |
that second one suggests perhaps calling
getListView().invalidateViews() in your PreferenceActivity (or, in your
case, PreferenceFragment, I guess)
|
Mark M. |
anyway, give that stuff a shot and hopefully it'll help
|
Mark M. |
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.
|
Steve B. |
(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()
|
Mark M. |
others have asked that, and it appears that MapView does not support setOnLongClickListener()
|
Mark M. |
for whatever reason
|
Mark M. |
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
|
Mark M. |
haven't tried GestureDetector for long-clicks
|
Mark M. |
onTouchEvent() is a method you override
|
Mark M. | |
Dec 6 | 4:25 PM |
Mark M. |
that's the project associated with the drag-and-drop example in the Advanced Android book
|
Dec 6 | 4:25 PM |
Mark M. |
the ItemizedOverlay implements onTouchEvent()
|
Mark M. |
you get a MotionEvent as a parameter
|
Mark M. |
it will tell you things like ACTION_DOWN, meaning the user placed a finger on the screen
|
Mark M. |
and so on
|
Mark M. |
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
|
Mark M. |
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
|
Mark M. |
and you do something
|
Steve B. |
Yes - I recall NooYawkTouch. I'll give that another look. Thank you!
|
Mark M. |
sure!
|
Mark M. |
Chaitanya: you said you had another question?
|
Chaitanya |
Yes
|
Chaitanya |
I apologize if this is a basic question, but I'm still learning how to effectively code in Java and use the Android SDK
|
Chaitanya |
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?
|
Chaitanya |
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
|
Dec 6 | 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
|
Mark M. |
along with flags indicating what they want
|
Mark M. |
and have the MenuDelegate handle that work
|
Mark M. |
or, use inheritance
|
Mark M. |
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
|
Mark M. |
(btw, howdy, zettie and Julius -- be with you momentarily!)
|
Chaitanya |
sorry but I didn't understand any of the suggested solutions
|
Chaitanya |
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
|
Mark M. |
and have other activities inherit from it
|
Mark M. |
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
|
Dec 6 | 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
|
Mark M. |
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
|
Mark M. |
again, none of this is unique to Android
|
Mark M. |
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
|
Mark M. |
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"
|
Mark M. |
and really it would need to be a week-long class, but I probably don't know enough to fill that time :)
|
Mark M. |
HTTPS on Android is not significantly different that HTTPS anywhere else
|
Mark M. |
done right, it solves the problem of people intercepting the data between you and the server
|
Dec 6 | 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
|
Mark M. |
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
|
Mark M. |
Julius: do you have a question?
|
Julius |
yes:)
|
Julius |
View paste
|
Julius |
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
|
Julius |
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 :)
|
Julius |
thanks all the same
|
Mark M. |
sorry!
|
Mark M. |
Steve: do you have another question?
|
Julius |
appreciate your itme
|
Julius |
time
|
Dec 6 | 4:45 PM |
Mark M. |
OK, does anybody have another question?
|
Julius |
well...
|
Julius |
:)
|
Julius |
do you know if there is a place to go to see how the styles are implemented
|
Julius |
sort of like a reverse lookup
|
Mark M. |
that depends on what you mean by "the styles"
|
Mark M. |
for the SDK, they're in your SDK itself
|
Mark M. |
$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
|
Mark M. |
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
|
Julius |
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
|
Julius |
(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
|
Julius |
I might try bring it up a hangout
|
Julius |
at at ^
|
Julius |
at a
|
Dec 6 | 4:50 PM |
Steve B. | has left the room |
Mark M. |
any other questions from anyone?
|
zettie | has left the room |
Dec 6 | 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
|
Julius |
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)
|
Julius |
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
|
Mark M. |
oh, well, now, that should be interesting
|
Julius |
I think after that you go into a lottery of sorts
|
Julius |
but I'm not sure
|
Julius |
don't hold me to it!
|
Dec 6 | 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
|
Mark M. |
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
|
Julius |
yeah that's true
|
Julius |
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
|
Julius |
oops 111 I better let you go
|
Julius |
yeah
|
Julius |
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
|
Julius |
bfn
|
Julius | has left the room |
Mark M. | turned off guest access |