Office Hours — Today, February 2

Tuesday, January 27

Feb 2
1:50 PM
Mark M.
has entered the room
Mark M.
turned on guest access
Mark M.
turned off guest access
2:20 PM
Mark M.
has left the room
7:25 PM
Mark M.
has entered the room
Mark M.
turned on guest access
Venkat
has entered the room
Mark M.
hello, Venkat!
how can I help you today?
7:30 PM
Venkat
Good day Mark
I am using a websocket created by AndroidAsync
and need to reconnect in case of network disconnections
can I create a dynamic broadcast receiver from a service?
Mark M.
if you mean, can you call registerReceiver() on a Service, the answer is: yes
Venkat
I tried but I do not get any brodcasts if the application is not active
Mark M.
what does "if the application is not active" mean?
Venkat
I mean if the main activity is not in the foreground
I am creating a local service which handles the websocket connection
sorry if I am not clear ... new to Android / Java
Mark M.
well, I'll admit to never having tried registerReceiver() on a Service, but since the method is defined up on Context, it'll certainly compile
which broadcast are you trying to listen to? CONNECTIVITY_ACTION?
Venkat
yes, please
Mark M.
AFAIK, that should be something you can listen to from a receiver registered via registerReceiver(), whether on a Service or an Activity
7:35 PM
Mark M.
another approach would be to have the receiver registered in the manifest, but then enable and disable it as needed from your service
Venkat
My broadcast receiver has a listener variable which points to the service, if I register it through the manifest then this variable is always null
Mark M.
your manifest-registered receiver would call startService() to send a command to the service, starting it if it is not already running
Venkat
so I was unsure how I can call the reconnect function from the receiver if registered from the manifest
ok ... will give it a try
7:40 PM
Mark M.
if you have another question, go right ahead
Venkat
Just a small query - in one of your answers in SO, you refer to the Weather API sample from the advanced guide, do you plan to cover it in the omnibus version of teh book?
Mark M.
no, I replaced that with the Stack Overflow client
Venkat
ok .. will check that out
7:45 PM
Venkat
No more questions for now ... will test out calling startService() from the receiver
Mark M.
OK
8:15 PM
moffitj
has entered the room
8:20 PM
Mark M.
hello, moffitj!
moffitj, do you have a question?
moffitj
I do
I'm trying to set up two-way communication between my xmpp GCM server and my phone. Upstream messages work beautifully. However, downstream messages appear to be empty. I can see from the Smackxmpp debug window that the packet was sent and contains a data field with key:value pairs, but when it arrives in my service and I call intent.getExtras().getString("valuethatIsetonserver"), the result is null.
What could cause the intent passed to my service to not include the data that I sent frommy server?
Mark M.
have you dumped the entire extras bundle, to see if something is altering your keys?
moffitj
I did
View paste
I/EXTRA KEY SET﹕ KEY: message_type
I/EXTRA KEY SET﹕ KEY: event
I/EXTRA KEY SET﹕ KEY: google.message_id
I/EXTRA KEY SET﹕ KEY: android.support.content.wakelockid
The keys I was trying to send were command and userID
Mark M.
that would suggest that the key/value pairs are being eaten either at Google's servers or in the Play Services Framework's processing of what gets pushed down from those servers
I haven't played with CCS/XMPP on GCM
so I haven't looked to see what the XMPP stanzas should look like, etc.
8:25 PM
moffitj
I think I know the cause then. For some reason the smack debug window is showing all quotes as "
Mark M.
perhaps they're being entity-escaped when you're building the XMPP message
moffitj
I thought this was a display bug, since google happily acked it rather than nacked as a malformed stanza
Mark M.
maybe Google's servers are just being friendly :-)
moffitj
Thanks for the direction
moffitj
has left the room
Venkat
Mark, have got it working, thanks for your help
Mark M.
oh, good, glad to hear it
Venkat
has left the room
Mark M.
turned off guest access

Tuesday, January 27

 

Office Hours

People in this transcript

  • Mark Murphy
  • moffitj
  • Venkat