Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use SyncAdapter to sync with *local* gmail and facebook app data

For an app I need to develop, I need to be able to sync with both gmail and facebook data using a SyncAdapter. I'm hoping to sync with the local facebook and gmail apps (if available) instead their remote servers. Syncing with the local apps would mean less battery usage, less network usage, faster syncing, etc. Of course, if needed, I will set the correct permissions.

My questions:

  • If any of the apps (gmail/facebook) are available, is it possible to query them for data (messages, events, etc.)?
  • If not, is it possible to get an authentication token (or any kind of credential) from them that will allow me to query the server without the user needing to put in a username and password of each of them again?
  • If that's possible, is it also possible to automatically sync immediately after either of the facebook or gmail apps sync, so that I get new data as soon as they do?

If none of these are available, I guess I'll need to fetch the data myself, so that's not relevant for this question.

like image 589
android developer Avatar asked Jul 17 '12 23:07

android developer


1 Answers

I can't speak for Facebook, but the GMail app doesn't allow this. It used to work previously, but they have since secured it so that only Google apps can query the email content provider. The best you can do is get the number of messages with the labels API. You can get an authentication token (ClientLogin or OAuth2) for Google services using the standard Android AccountManager. You will then have to use it to connect to the particular API to get the actual data.

like image 195
Nikolay Elenkov Avatar answered Sep 23 '22 05:09

Nikolay Elenkov