Use Syncadapter To Sync With *local* Gmail And Facebook App Data
Solution 1:
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.
Solution 2:
Ah, now I've better understood your question. I don't think that there's any way to get the data you're interested in directly from the local copies of the apps. It's an interesting idea, and reasonable for the speed/space/bandwidth reasons you suggest, but would require significant support from the apps that's not currently available.
Trying to avoid the user re-entering their password is also something that would almost certainly still be impossible even if the apps did support sharing local data. After all, how is the GMail app going to verify that your app should have permission to read all of its data? Presumably by prompting for your GMail username and password. Merely being on the same device definitely doesn't imply complete trust.
Using a SyncAdapter and storing the authentication token as demonstrated in the sample project, you should be able to limit the user to entering their credentials once, but that's about the best you're going to be able to do.
Previously:
Have you had a look at the SampleSyncAdapter included with the SDK?
These instructions give a quick overview of how to access the samples.
If you're using Eclipse, it's actually even easier then they suggest there. To get the sample project:
- Select
File
>New
>Other...
- Choose
Android
>Android Sample Project
- Choose whichever target/API Level is applicable to your project (probably the latest)
- Select the sample project you're interested in, SampleSyncAdapter in this case
The sample project is a great example of how to use SyncAdapters and should be readily adaptable to connect with GMail, Facebook, etc.
Post a Comment for "Use Syncadapter To Sync With *local* Gmail And Facebook App Data"