Office Hours — Today, June 21

Thursday, June 16

Jun 21
7:25 PM
Mark M.
has entered the room
Mark M.
turned on guest access
7:35 PM
Scott P.
has entered the room
Mark M.
howdy, Scott!
Scott P.
I'm back :-)
alrightSo I got pretty
*So I have something that I think is within your capability to help me with
I contacted Google for what the issue might be
and it sounds like the authorization token that I'm sending to the server is out of date
so I need to manually pull one in fresh from google
Do you know how to do that?
Mark M.
no offense, but you're going to have to refresh my memory of what you're talking about
Scott P.
right
c2dm
Mark M.
I barely remember what I had for breakfast this morning
:-)
the sum total of my C2DM knowledge is contained in that one chapter
and, since I've forgotten most of it in the past year, I'd have to read my own chapter to get caught up to myself
Scott P.
so Googles new GPE Beta integrates App Engine and Android together along with C2DM
Mark M.
ok
Scott P.
well I was looking through your chapter
and it looks like you use a curl script to do it?
Mark M.
ah, that token
7:40 PM
Scott P.
I'm not sure I fully understand how you execute the curl script
and I'm not sure how to pull a value from it
Mark M.
for the purposes of the book, lacking an app server, curl is a reasonable stopgap
a real server process would use something more sophisticated
I think the C2DM samples show a servlet for the server-side, getting and managing the auth token
(C2DM samples from Google, that is)
the curl script is designed to be pasted into a command line and run
given that you have curl in your path
and you adjust the parameters as needed
it's designed for developers for lightweight testing, not for production use
Scott P.
so I can't do that from my android phone?
Mark M.
you'
you're not supposed to do that on the client side
that's for the server side
where the curl scripts are a stopgap replacement for a real server
Scott P.
hmmm, really?
Mark M.
again, you're asking a guy who hasn't touched this in ages and, as usual, is short on sleep
but I am really really sure that the curl scripts are not supposed to run on the device
Scott P.
It seems that I need to have an authention token that I send from the phone to the server
Mark M.
the equivalent of those scripts would either be part of your GAE environment, or possibly manually run with the results added to some configuration data your GAE stuff runs
Scott P.
blah
Mark M.
there are multiple tokens involved
Scott P.
ok
Mark M.
in my book, I have an activity and broadcast receiver, demonstrating the client side portion of matters
Scott P.
yup
Mark M.
hold on
Scott P.
hmmm
ok
Mark M.
View paste
When the registration occurs, you will be notified by a broadcast Intent,
containing a registration ID. Google's C2DM client code will route that to
an IntentService, where you can do whatever is necessary. A typical thing to
do would be to make a Web service call to your server, supplying the
registration ID, so the server knows how to send messages to your
application on this device.
7:45 PM
Mark M.
(from page 454 of the Advanced Android book)
the registration ID is the "token" that is on the client side
Scott P.
right
wait
no
Mark M.
View paste
At this point, given the registration ID, the server is able to send messages
to your app. It will do this by first getting a valid set of authentication
credentials – effectively turning the Google account name and password
into a long-lived authentication token. Then, your server can do an HTTP
POST to the Google C2DM servers, supplying that authentication token,
the registration ID of the app, and whatever data should be passed along.
(also from page 454)
Scott P.
I'm refering to something called the Authentication Token. The Authentication Token is sent to the Server, and is used to generate a registration cookie
Mark M.
the "authentication token" is basically the result of ClientLogin, indicating that your server is authorized to send requests to the C2DM servers
Scott P.
the cookie is then sent back to the device
then that cookie is used to register to c2dm
Mark M.
the "authentication token" is *exclusively* a server-side concept
at least with C2DM the way it was a year ago
Scott P.
hmmm
Mark M.
now, I have never used GAE, let alone for this other stuff you're talking about
I have no idea what the GAE frameworks are for sending stuff via C2DM
Scott P.
it's all hiidden and done behind the scenes so I can't really tell either
I suppose I'll just e-mail back and ask for a work around
Mark M.
then you need to be talking to the GAE folk
Scott P.
thanks
Mark M.
the authentication token, as I recall, is something that will be useful for a while but will eventually be revoked due to age
IIRC, you actually will get an updated token as part of doing C2DM calls, via a custom header
Scott P.
IIRC?
Mark M.
so, in theory, you'd use the curl stuff to bootstrap your initial token, and your app server would update its cached copy based on the custom headers if a new token is handed to you
"if I recall correctly"
Scott P.
hmmm
ok
Thanks, I appreciate it
Mark M.
sorry I can't be of greater help
7:50 PM
Mark M.
C2DM is one of those topics I covered for the sake of covering it, more so than something I use or interact with regularly
Scott P.
it's ok. I just thought I'd exhaust my other resources before I bothered them for a workaround
Mark M.
is there anything else I can help you with today?
Scott P.
I think that's it
7:55 PM
Mark M.
well, if you think of something, I'm here for another ~35 minutes or so
7:55 PM
Scott P.
1 more small question I suppose. Do you know of a way when reading the SMS content provider to tell whether or not an SMS is one recieved or one that is sent?
Mark M.
since there is no SMS content provider in the Android SDK, I don't know much
I assume you're referring to the content provider used by the AOSP Messaging app
Scott P.
AOSP?
Mark M.
Android open source project
Scott P.
I suppose
Mark M.
that app may not be on any device and, even if it is, may be modified by the OEM
developers shouldn't be relying on that content provider for much of anything
Scott P.
I've read your posts on stackoverflow about that
and even read the linked articles
Mark M.
I'm a bit of a broken record on the subject
Scott P.
however it's unavoidable when there is no point to having the app if it can't use the functionality that this provides
that being said, are there any known devices that don't implement it in some form or another?
Mark M.
beats me
Scott P.
I suppose it's possible t hat they don't include it or take it out
Mark M.
and it is only "unavoidable" if you write this app
8:00 PM
Mark M.
or Google refactors it
or Google renames it
the similarly-unsupported calendar content provider had this happen
fortunately for those who depended upon it, the change was relatively minor
and, for calendar, there's always the Google Calendar APIs as an alternative access method
personally, I wish Google would step up and make the SMS content provider part of the OS
I even spoke to an engineer about that at I|O
Scott P.
Well that change would only happen for future versions correct, so why wouldn't a version check with different cases for how to handle it be a simple work around?
what did they say?
Mark M.
for those narrow cases, perhaps
the engineer basically said that it's not a priority
Scott P.
I really feel like they need to make hardware acceleration a priority on the default home screen
it amazes me they haven't done that yet.
It makes the android experience feel slow and laggy compared to iOS
Mark M.
it's accelerated in Honeycomb
Kathy
has entered the room
Mark M.
and will be going forward
Scott P.
but that's tablets
I haven't seen anything in terms of phones
Mark M.
"going forward" = Ice Cream Sandwich = phones
Kathy
Hello everyone.
Mark M.
howdy, Kathy!
Scott P.
oh snap
Hi Kathy
Mark M.
Kathy: do you have a question?
8:05 PM
Kathy
yes, I do.
Mark M.
Kathy: go ahead with your question
Kathy
I am doing a display of text in three columns and an undetermined number of rows. I have been playing around with gridview to do this. I do not want the words, to be clickable. I want to propagate the rows and columns from a string array. I have been looking at the google grid example but it is using images and listeners. I have also looked at your example and it is using a listener.
Mark M.
sounds like a TableLayout, perhaps wrapped in a ScrollView if it might exceed the bounds of the screen
8:10 PM
Kathy
I thought the grid layout might do some things automatically like the scrolling. I was first playing with a table layout and trying to propagate the rows and columns dynamically, but then it looked like a grid might be better, of course I may be wrong.
Mark M.
well, GridView cells are clickable, because that's the objective of any AdapterView
Scott P.
Alright Mark. It's been a pleasure talking with you again. See you later.
Mark M.
Scott: see ya!
Kathy
Okay, then I should go back to the table layout then? If so, is there a good example I could look at that would let me use a string array and a dynamic number of rows?
Mark M.
you'd have to construct the rows in Java code, rather than via a layout XML resource
I don't have any examples of that handy
nor can I think of any off the top of my head
8:15 PM
Mark M.
most of the time, people are looking for the input, and so GridView works
Kathy
I guess I could use a listener with gridview and just ignore the clicks?
Mark M.
the downside there is that users will see the visual response to the clicks and wonder why nothing is happening
are you sure there's nothing you could/should be doing when the user clicks on a cell?
Kathy
yeah, that would be bad.
I can think on it, but right now no.
Mark M.
well, iterating over the string array and creating TextView and TableRow widgets in Java will be annoying, but certainly doable
Kathy
Yes, I could do that. I like to use things as vanilla as possible, but then I want things that are not.
8:20 PM
Scott P.
has left the room
Kathy
Thanks for your help on this and helping me to increase my understanding.
Mark M.
sorry I didn't have a better answer for you
Kathy
No problem and no worries.
On a different note, is there some sort of master index for your books? I would like to be able to look at some sort of index for example gridviews and get a list of which books and where thay are at.
Mark M.
not really
given that they're digital, most people just use search
if your desktop environment has an integrated document indexer, and it indexes PDFs, you might be able to search all three at once that way
or, search them individually from your PDF reader
or, create a concatenated copy of all three PDFs, and search that from your PDF reader
Kathy
I have been pulling each book individually up in pdf and doing it that way. Is there a better way?
Mark M.
there are various packages available to concatenate PDFs, which you could use to create a master PDF for searching, but then you'd need to update that with every book release
8:25 PM
Kathy
Well, those were the only questions I have for now. I very much appreciate your time and help.
Mark M.
happy to be useful
Kathy
Good bye.
Mark M.
see ya!
8:30 PM
Kathy
has left the room
Mark M.
turned off guest access

Thursday, June 16

 

Office Hours

People in this transcript

  • Kathy
  • Mark Murphy
  • Scott Pierce