Jan 15 | 7:25 PM |
Mark M. | has entered the room |
Mark M. | turned on guest access |
EGHDK | has entered the room |
Mark M. |
howdy, EGHDK!
|
Mark M. |
how can I help you today?
|
Jeff D. | has entered the room |
EGHDK |
Hey Mark. Couple of questions.
|
Mark M. |
(BTW, hi, Jeff -- be with you shortly!)
|
Mark M. |
EGHDK: give me your first one
|
Jeff D. |
No issues.
|
EGHDK |
Okay, so I'm not sure if you'll be able to answer
this question. But, I have a server and I have my mobile application.
What is the best way to get them to communicate. I don't feel like I'm
doing it the correct way as of right now.
|
Mark M. |
um, could you be a bit more specific? :-)
|
EGHDK |
Yes, sorry, I'm writing up something more specific right now.
|
Jan 15 | 7:30 PM |
EGHDK |
I should get more prepared for these things in the future. lol
|
Mark M. |
Jeff: do you have something quick while EGHDK organizes?
|
Jeff D. |
sure... pg 138...
|
Jeff D. |
View paste
|
Mark M. |
OK
|
Mark M. |
OnClickListener only tells you it was clicked, not the new state
|
Jeff D. |
sorry...had a word document with my questions.
Now I know that not all cases are good for setting the 'onclick' in the
XML...and im getting to that with fragments
|
tunneling | has entered the room |
Mark M. |
if you have more than one CompoundButton for which
you are using the same object as the OnCheckedChangeListener, you would
need to compare IDs, but we have only one
|
Jeff D. |
so you didn't test for the ID of the object, as you didn't really need to.
|
Mark M. |
CompoundButton is the parent class of CheckBox and handles all two-state widgets, which is why the "checked" stuff is there
|
Jeff D. |
Ahhhh, o.
|
Jeff D. |
ok.
|
Mark M. |
CompoundButton, however, is an abstract class, so we have to create things like CheckBox, ToggleButton, Switch
|
Mark M. |
the parameter to onCheckedChange() is the CheckBox (or other CompoundButton) whose state was changed
|
Jan 15 | 7:35 PM |
Mark M. |
and you need
CompoundButton.OnCheckedChangeListener because I am not importing that
interface directly, and CheckBoxDemo does not inherit from
CompoundButton
|
Mark M. |
note that most of this has little to do with Android and everything to do with Java
|
Mark M. |
(BTW, howdy, tunnelling -- be with you shortly)
|
Mark M. |
EGHDK: ready?
|
Mark M. |
:-)
|
tunneling |
Just hanging...
|
Mark M. |
tunneling: OK
|
EGHDK |
View paste
|
Mark M. |
"Would it be better to fetch this data from the mysql database directly?" -- oh, $DEITY, no
|
Jeff D. |
EGHDK...you are on a totally different level than I am currently. man.
|
Mark M. |
that would imply that your database server was open to the Internet and that your account credentials were baked into your app
|
Mark M. |
neither is a great plan
|
Peri H. | has entered the room |
Mark M. |
the typical approach is to create a REST-style Web service, hosted by your Web server, that serves up your data
|
EGHDK |
"EGHDK...you are on a totally different level than I am currently. man." what's that mean? hah.
|
EGHDK |
View paste
|
Mark M. |
you are welcome to attempt to parse the HTML you
get back from the regular Web server, but then if you do a redesign of
the site, your app may break
|
EGHDK |
Makes sense.
|
Jeff D. |
EGHDK, I'm still figuring the basics out and you are communicating across sites and using SQL.
|
Mark M. |
the Web service can provide a measure of security that your database won't know how to
|
Mark M. |
and, if the user has an account, you can use
things like OAuth to try to use the same authentication logic for both
the site and the app
|
EGHDK |
@M
|
Mark M. |
all of that, though, is kinda beyond the scope of the book, and to a large extent, this chat
|
EGHDK |
Gotcha.
|
Jan 15 | 7:40 PM |
Mark M. |
let me take questions from the others, and I'll be back with you shortly
|
Mark M. |
Peri: do you have a question?
|
Peri H. |
Hi Mark.
|
Peri H. |
Yes, I might want to ask about syncadapters.
|
Mark M. |
I haven't used them, so I may not be much help
|
Mark M. |
they're on my list of things to get into in the first half of 2013
|
Peri H. |
I want to address the issue of references from my app to contacts and events.
|
Peri H. |
I have this working quite well righ tnow, using Events._ID and Contacts.LOOKUP_KEY.
|
Peri H. |
However, if the user clears his contacts or
events, this breaks. It breaks any time the user deletes something in
contacts or events externally, but that isn't too hard to deal with.
|
Peri H. |
The hard part is when they're completely deleted.
Then they all get a new set of keys, which may arbitraily match keys in
my apps db.
|
Peri H. |
Any suggestions?
|
Mark M. |
"whicih may arbitrarily match keys in my apps db"
-- meaning LOOKUP_KEY may have the same value, for different contacts,
before and after the bulk deletion?
|
Peri H. |
Less likely for LOOKUP_KEY, but it's pretty easy to make happen with Events.
|
Mark M. |
yeah, ideally, they would have a similar sort of durable identifier for events
|
EGHDK |
Last questions on this app-to-server topic. Since
my application doesn't require users to log in or anything. Let's just
say I have a daily menu I need to get fetched every day they open the
app, I don't need any fancy oAuth stuff right? What would you recommend?
As "REST-style web service" doesn't mean much to me. Should I just
Google that phrase?
|
Jan 15 | 7:45 PM |
Peri H. |
Event ids start at 1 each time you clear the Events table.
|
Mark M. |
(EGHDK: hang on, I will be with you in a bit)
|
Mark M. |
yeah, I am not seeing anything on CalendarContract.EventsColumns that looks like a durable identifier
|
Peri H. |
So, I think the tactic would be to have my own set of UIDs paired with Events (and Contacts).
|
Peri H. |
It seems that SyncAdapters give you write-access
to several columns that could be used for UIDs. Do you know of any
other way to do this?
|
Mark M. |
I don't know what the rule is for those
SYNC_DATA... columns, but if you can use one for your purposes, yes,
having your own UID (or UUID) may work
|
Mark M. |
off the top of my head, no
|
Peri H. |
Any one else know :)
|
Mark M. |
but I have not worked with CalendarContract
|
Mark M. |
that feels like a good StackOverflow question
|
Peri H. |
Ok, off I go...
|
Peri H. |
Thanks.
|
Mark M. |
Jeff: do you have another question?
|
Jeff D. |
195 - Iconic Adapter extends the normal
ArrayAdapter…the construct is a different one…valid, but different than
normal for the superclass. What does this give us? I can’t find it in
the google docs
|
Peri H. |
By the way, if you want to try the app, it's now available at: https://play.google.com/store/apps/details?id=c...
|
Mark M. |
"What does this give us?" -- it gives us a constructor
|
Mark M. |
it isolates some of the details inside the adapter
|
Mark M. |
but you are welcome to do it other ways if you want
|
Mark M. |
and, again, this has little to do with Android and everything to do with Java
|
Jeff D. |
thats kinda what I was guessing, but i wanted to
make sure I was interpreting it correctly...i can see why we are doing
something a certain way.
|
Peri H. | has left the room |
Jeff D. |
when you say that, you mean that a lot of the items are normal ops for Java and not really tied to Android?
|
Jan 15 | 7:50 PM |
Mark M. |
constructors are part of Java
|
Jeff D. |
yes, very true
|
Mark M. |
inheritance and polymorphism are features of Java (from your first question)
|
Mark M. |
they are being *applied* here in Android
|
Jeff D. |
that constructor was different as it took
different arguments...was trying to find something in the google docs
that could explain the nature of this particular constructor better and
why we chose this one.
|
Mark M. |
again, this is Java
|
Jeff D. |
Java is new to me, as I grew up in C/C++.
|
Mark M. |
you can create whatever constructors you want
|
Jeff D. |
yes...
|
Mark M. |
when you create a subclass, you will need to chain to the superclass using one of *its* constructors
|
Mark M. |
but frequently a subclass with have constructors with different parameters than the superclass has
|
Mark M. |
in my case, I elected to move a few things into the adapter and out of the activity
|
Mark M. |
I did not have to do that
|
Mark M. |
that was a personal choice
|
Mark M. |
let me take EGHDK's next question, and I'll be back with you in a bit
|
Mark M. |
(BTW, tunneling, if you come up with a question, let me know)
|
Jeff D. |
you bet...need to chew on that one.
|
Mark M. |
EGHDK: in your case, I am not quite certain what to tell you
|
Mark M. |
either parse the HTML, or create some other output from your server that is more reliable for the app to parse (JSON, XML, etc.)
|
Mark M. |
if all you are doing is consuming the data in the app, the Web site just has to serve something the app can read easily
|
Jan 15 | 7:55 PM |
Mark M. |
OK, if anyone has any questions, chime in
|
EGHDK |
Okay cool, so something like JSON should be pretty easy to do.
|
Mark M. |
simplest way is to just have a separate URL for the JSON stuff
|
EGHDK |
OHH. That makes sense.
|
EGHDK |
Okay, next question. I'm having this issue. http://code.google.com/p/android/issues/detail?...
|
EGHDK |
Or at least, my application is. Someone filed a bug report.
|
EGHDK |
There seems to be a solution, but I'm not sure how to solve it.
|
EGHDK |
Answer?: "regenerate the support-library from the sdk"
|
Mark M. |
yes, you just filed this a minute ago on StackOverflow :-)
|
EGHDK |
Yes!
|
Mark M. |
well, the solution is in the question
|
EGHDK |
I like to take advantage of office hours. I know. hahah
|
Mark M. |
first, make sure you are on the latest Android Support package, in case this was already fixed and they never updated the issue
|
Mark M. |
the source code to the Android Support package is in your SDK
|
Jan 15 | 8:00 PM |
EGHDK |
Okay, so that brings me to another question. Is there a resource to find the newest ASP?
|
Mark M. |
in the same basic spot where you got the JAR from, if you did that manually (vs. via the Add Support Library menu in Eclipse)
|
Mark M. |
it's in your SDK Manager
|
Mark M. |
based on the source code, the latest Android Support package appears to have the fix
|
EGHDK |
Because I get confused with the version numbers.
|
Mark M. |
if the SDK Manager says that you're on the latest, then you're on the latest
|
Mark M. |
however, you have to copy over the JAR to your project
|
EGHDK |
like v11 of Support package and v4 of support package. I get confused.
|
EGHDK |
Is 4 the newest or 11 the newest?
|
Mark M. |
yeah, neither of those are versions of the *package*
|
Mark M. |
they are referring to API levels
|
Mark M. |
hence, neither is the newest, with respect to the Android Support package's own version
|
EGHDK |
Oh. Okay, I should really look into that because it's confused the crap out of me.
|
Mark M. |
in the SDK Manager, in Extras, you will see Android Support Library
|
Mark M. |
if the Status column says "Installed", you have the latest edition
|
EGHDK |
So right now, I should go into eclipse and delete the ASP, and then manually right click my project and re add it?
|
Mark M. |
if the Status column says something like "updates available", then updates are available :-)
|
Mark M. |
in your project, in libs/, you will have android-support-v4.jar (or something like that)
|
Mark M. |
you will need to replace that with the new version of the JAR from the update you get from the SDK Manager
|
EGHDK |
Nope I have Android Support library version 11.
|
EGHDK |
So I'm up to date.
|
Mark M. |
but is that what you're shipping on the Play Store?
|
Mark M. |
IOW, how long has it been since you did a production build and released it on the Play Store?
|
EGHDK |
I released a new version last week.
|
Jan 15 | 8:05 PM |
EGHDK |
But, I don't know if it has the newest .jar
|
Mark M. |
and, comparing your stack traces, the one in your StackOverflow question does not match the issue you linked to here
|
Mark M. |
the issue is complaining about android.app.Notification$Builder.setProgress
|
Mark M. |
your crash is android.support.v4.app.NotificationCompatIceCreamSandwich.add
|
EGHDK |
Bah.
|
Mark M. |
oh, no, wait
|
Mark M. |
never mind
|
EGHDK |
Dangit. Sorry.
|
Mark M. |
hang on
|
EGHDK |
?
|
Mark M. |
your SO question is strange
|
EGHDK |
Hahaha. I just erased it.
|
Mark M. |
oh, wait, now I get it
|
Mark M. |
(that's OK, I still have the browser window open)
|
Mark M. |
add() is where the crash occurred
|
Mark M. |
the error is the one from the issue
|
EGHDK |
Hrm.
|
Mark M. |
however, I suspect that the JAR in your project is older than the rev-11 version from the SDK Manager
|
Mark M. |
again, according to the source code for the Android Support stuff, this bug is fixed
|
EGHDK |
Okay,
|
Mark M. |
you can compare dates/file sizes of the JARs
|
Mark M. |
the one in your project
|
Mark M. |
and the one in your SDK installation
|
EGHDK |
So how do I re-add the new one into my project?
|
Mark M. |
drag it into Eclipse's libs/ directory
|
Mark M. |
it will replace the one you have
|
Mark M. |
extras/android/support/v4/android-support-v4.jar
|
Mark M. |
but check the files first
|
Mark M. |
if the one in your project is much older, then this is likely the reason for the recent crash
|
Mark M. |
and copying over the newer JAR will (hopefully) fix it
|
Mark M. |
Jeff/tunneling: if either of you have a question, chime in
|
EGHDK |
Okay my file in the project is 349,252 bytes, the one in my sdk extras 385,685 bytes.
|
Jan 15 | 8:10 PM |
EGHDK |
So, that seems that it could be the fix... correct?
|
Mark M. |
it's likely
|
Mark M. |
can't guarantee it, but it's likely
|
tunneling | has left the room |
EGHDK |
Okay, so in my extras/android/support it has v4 v7 and v13.
|
Mark M. |
go into v4
|
EGHDK |
Those aren't "version numbers"... you said right.
|
Mark M. |
those are API levels
|
EGHDK |
Hmm... so v4 supports down to api lvl 4?
|
Mark M. |
everything in extras/android/support is now rev 11 from the SDK Manager
|
Mark M. |
um, sorta
|
Mark M. |
it's more that if you are developing for older than API Level 11, you want the -v4 JAR
|
Mark M. |
if you happen to be developing for API Level 11+,
and just need some compatibility stuff related to ICS/JB, that's what
-v11 is for, IIRC
|
EGHDK |
OHH. This makes so much more sense. Thank you so much. The light bulb just turned on. And all the dots connect. hahah. Awesome.
|
Mark M. |
v7 is actually not a JAR, but is a backport of GridLayout as an Android library project
|
Mark M. |
and I really wish they wouldn't have made all that so confusing
|
EGHDK |
I don't have any v11
|
EGHDK |
just v4 v7 and v13.
|
Mark M. |
oh, sorry
|
EGHDK |
Just sayin. lol
|
Mark M. |
replaceAll("11", "13")
|
EGHDK |
Should I?
|
Mark M. |
no, I just was mis-remembering and wasn't looking at my own directory tree
|
EGHDK |
Gotcha. Okay so last thing on this bug report I recieved.
|
EGHDK |
How can I tell what version of android this user had?
|
Jan 15 | 8:15 PM |
Mark M. |
where did you get the stack trace from?
|
Mark M. |
from the Play Store Developer Console?
|
Mark M. |
or by some other means?
|
Jeff D. |
Mark, while he is typing you mind if I jump in?
|
EGHDK |
Play store.
|
Mark M. |
Jeff: please chime in -- I'll try to time-slice between you
|
Jeff D. |
Ok. Ok, I need to go over this a bit more…. You
set list adapter via (new IconicAdapter()). This calls the
construct…and you are chaining up to the super class (Array Adapter)….
Its taking the DynamicDemo Class, which is being used to do our
ListActivitity, …why are you passing the layout.row (XML?), and the id
label, in addition to the item array? I know its part of an established
constructor, but what are you trying to accomplish? I may need a
'barney style' breakdown to get it through my skull.
|
Mark M. |
EGHDK: I don't have anything currently in the Play
Store, but I was under the impression that the Play Store error reports
were a bit sparse on information, like the OS version
|
Mark M. |
EGHDK: you might try ACRA: http://acra.ch
|
Mark M. |
"why are you passing the layout.row (XML?), and
the id label, in addition to the item array?" -- because ArrayAdapter's
constructor needs them
|
Mark M. |
"but what are you trying to accomplish?" -- it
helps if our list has data and a format for our rows, otherwise we will
not see anything
|
Jan 15 | 8:20 PM |
Mark M. |
you may want to go back to the beginning of the chapter
|
Mark M. |
where all of that is explained
|
Mark M. |
mostly page 172
|
Jeff D. |
ok.
|
Mark M. |
EGHDK: I use ACRA with BugSense as the server
component for the APK version of the book, and I get OS version
information in my crash reports
|
Jan 15 | 8:25 PM |
EGHDK |
Cool, I'll check that out. In the meantime, I think I'll quickly push an update.
|
Jeff D. |
For the getView(), does Android call that whenever it needs to draw/display a new row?
|
Mark M. |
Jeff: yes
|
Jeff D. |
I'll go over the AdapterViews and Adapters chapter
tomorrow...i had some holder questions as well, but I really should
just go bac over this.
|
Mark M. |
any last questions?
|
Jeff D. |
Page 252 Options Menus and the Action Bar– does
adding a new word to the arrayadapter also add it to the arraylist?
Once you setup the arrayadapter to feed off of the arraylist, does it do
this automatically?
|
Mark M. |
ArrayAdapter has add(), insert(), and remove()
methods that update the backing store (ArrayList) in addition to telling
the ListView "yo! our data changed!"
|
Jan 15 | 8:30 PM |
Jeff D. |
Awesome.
|
Jeff D. |
No futher here, appreciate the time.
|
Mark M. |
and that's a wrap for today's chat
|
Mark M. |
the transcript will be posted at http://commonsware.com/office-hours/ shortly
|
Mark M. |
the next chat is Thursday at 7:30pm Eastern
|
Mark M. |
have a pleasant day!
|
Jeff D. |
Thanks for your help.
|
EGHDK | has left the room |
Jeff D. | has left the room |
Mark M. | turned off guest access |