Office Hours — Today, March 27

Friday, March 23

Mar 27
3:55 PM
Mark M.
has entered the room
Mark M.
turned on guest access
4:00 PM
Scott
has entered the room
Mark M.
howdy, Scott!
how can I help you today?
Scott
hi
you can make more mistakes so i can extend - joking
Mark M.
?
Nitin S.
has entered the room
Mark M.
howdy, Nitin!
Scott: do you have a question?
Scott
do you have any idea how to prevent a user from stopping or deleting an app/service?
Mark M.
that's not possible
users can Force Stop anything they want
and the only apps that cannot be deleted are those that are preinstalled
Nitin S.
Hi Mark !
Scott
could i send email if service is stopped ?
Mark M.
if the user presses Force Stop, your whole process goes "poof", and you will not be able to send an email, etc.
Nitin: do you have a question?
4:05 PM
Nitin S.
yes
I wanted to know the "authTokenType" for one of the accounts listed in the Accounts & sync settings. Is that possible? If yes, how?
Mark M.
sorry -- I have no idea
I have not yet worked with the AccountAuthenticator and related classes
Nitin S.
Ohh.. you have any idea how to get X-Auth-Token from an https server?
Mark M.
how are you accessing the server? HttpClient? HttpUrlConnection? WebView? other?
Nitin S.
since its a secure server, i should be using HttpsUrlConnection right?
Mark M.
I meant more in terms of the general API
Scott
i have app that puts device in airplane mode if speed >= 12mph - uses:
Mark M.
any of those could use HTTPS
Nitin: so, is your code using HttpUrlConnection/HttpsUrlConnection?
4:10 PM
Mark M.
or something else?
Nitin S.
i have a set of URLs and to access them, i should be stuffing my header with the X-Auth-Token obtained from the login page..
Https*
its using Https*
i mean i don't have a code now. I want to know how should I go about getting that token? It might be a lamest question as this is the 1st time I am working on a web app..
Mark M.
Step #1: Decide what Java classes you will be using to process "the login page"
Nitin S.
X-Auth Token can be obtained if the user enters username and password in the login page..
Mark M.
Step #2: Find in those Java classes how to retrieve a header from your response
Nitin S.
ok..
Mark M.
with HttpUrlConnection, that would be getHeaderField()
Scott: do you have another question?
Scott
yes, sorry i interrupted Nitin
Nitin S.
No probs. :)
Scott
how to tame LocationManager battery use
View paste
		mgr.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 120000, 25.0f,
				onLocationChange);
		mgr.requestLocationUpdates(LocationManager.GPS_PROVIDER, 120000, 25.0f,
				onLocationChange);
4:15 PM
Scott
the above works great,but really sucks battery
so, i'm trying to use your "wakeful" to wake up and get just a single fix from LocationManager
Mark M.
you'd want the LocationPoller for that
it's a separate project
Scott
ah !! glad i asked
Mark M.
IntentService is not good with listeners
because it wants to shut down once onHandleIntent() ends
LocationPoller is wakeful, but not an IntentService
it's designed for use with AlarmManager for finding your location sporadically
Scott
i'm looking for speed, actually
Mark M.
if your location provider supports it, no problem
Scott
when i used battery sucking code i got good speeds from gps
Mark M.
let's swing back to Nitin
Scott
ok,thanks
Mark M.
Scott: GPS should handle speed reasonably well
Nitin: do you have another question?
4:20 PM
Mark M.
ok, Scott, back to you...
Nitin S.
I was wondering which of the two way i should be using to get the Token. 1. Using AccountManager 2. Using the Login Activity and then using HttpPost?
Mark M.
Nitin: I have no idea
again, I have not used AccountManager
Nitin S.
Okay.
Could you please let me know how to use HttpPost with the HttpsUrlConnection?
Mark M.
HttpPost has nothing to do with HttpsUrlConnection
they are completely separate APIs
HttpPost is for use with HttpClient
you can read about HttpClient in _The Busy Coder's Guide to Android Development_, in the chapter on Internet access
HttpUrlConnection/HttpsUrlConnection have been a part of standard Java for over a decade, and are covered in many online resources
Nitin S.
Sure. I should read that. Thank you.
4:25 PM
Mark M.
if either of you have questions, chime in
Scott
no, the location poller may be what i am trying to do - i do have it working using your "wakeful" pattern,but i don't get good speedseven though loc.hasSpeed() istrue
Mark M.
are you testing using hardware?
or the emulator?
Scott
motorola bravo phone
Mark M.
so you are getting a Location with lat/lon but no speed, from GPS_PROVIDER?
Scott
yes
Mark M.
that's odd
LocationPoller is unlikely to change that behavior
4:30 PM
Mark M.
it's conceivable that you won't get speed until the second or subsequent fixes, I suppose
I have never looked at speed values in Location
Scott
i am calculating my own speed from 2 positions - kinda works
i also tried letting it wake up and getting multiple fixes - speed always 0 even though .hasSpeed() returnstrue....
Mark M.
you might consider posting a question to the MOTODEV support boards, in the off chance this is something Bravo-specific
Scott
gives me perfect speed when i don't use alarm to launch LocationManager every fewminutes
Nitin S.
i hv a question.
Mark M.
Nitin: go ahead
Nitin S.
Can you give me a brief overview as to how google calendar syncs with the calendar app in the user's device? What APIs I can use for syncing my web calendar with the calendar app?
Mark M.
Scott: my best guess is that GPS needs to process 2+ fixes to start reporting speed, but that is just a guess
Nitin: On Android 4.0+, there is CalendarContract
I have a short chapter on that in _The Busy Coder's Guide to Advanced Android Development_
there is no documented/supported API for the Calendar app before Android 4.0
4:35 PM
Nitin S.
so it it that I can do the syncs in Gingerbread, Froyo?
i would study that.
I cant*
Mark M.
the app certainly syncs going back to earlier than 4.0
whether or not any of the sync APIs in Android let you manipulate that behavior, I cannot say
if either of you have any questions, chime in
4:40 PM
Nitin S.
I want my app to do the syncing even in Gingerbread. How is that possible?
Mark M.
I have no experience with AccountAuthenticator, AccountManager, or any of the syncing APIs
Nitin S.
Okay.
Thank you. I am done for the day. Have a nice day. :)
Mark M.
you too!
Nitin S.
has left the room
4:45 PM
Scott
i have to go drive somewhere to test my app so thanks for your help - and appreciate the sample codeverymuch
Mark M.
no problem! drive safely! :-)
Scott
has left the room
5:00 PM
Mark M.
turned off guest access

Friday, March 23

 

Office Hours

People in this transcript

  • Mark Murphy
  • Nitin Sethi
  • Scott