Reply to comment

Android - run your SyncAdapter immediately

Android has great support for server <-> client synchronization. There is lot of thinks to implement and the documentation is not fully complete, but it worth.

When you want to know more about SyncAdapters, ContentResolvers, ContentProviders and AccountAuthenticators you should read Sample Sync Adapter example on Google's Android developer site.

Now what to do, when your synchronization is ready to use and you want to allow user to fire "sync now" action? It's just a few lines of code:

Bundle bundle = new Bundle();
bundle.putBoolean(ContentResolver.SYNC_EXTRAS_EXPEDITED, true);
bundle.putBoolean(ContentResolver.SYNC_EXTRAS_FORCE, true);
bundle.putBoolean(ContentResolver.SYNC_EXTRAS_MANUAL, true);
ContentResolver.requestSync(null, MyContentProvider.getAuthority(), bundle);

Just call the above code and your Android device will we synchronized immediately, even if background data are disabled (thanks to "SYNC_EXTRAS_MANUAL")!

Enjoy syncing!

Reply

  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <h2> <h3> <h4>
  • You can enable syntax highlighting of source code with the following tags: <code>, <c>, <cpp>, <csharp>, <css>, <drupal5>, <drupal6>, <html>, <java>, <javascript>, <latex>, <mysql>, <php>, <postgresql>, <python>, <ruby>, <sql>, <xml>. The supported tag styles are: <foo>, [foo].
  • Lines and paragraphs break automatically.

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Enter the characters (without spaces) shown in the image.

© 2012 Vladislav Skoumal |
Webmail Home Back To Top