diff --git a/docs/html/training/sync-adapters/running-sync-adapter.jd b/docs/html/training/sync-adapters/running-sync-adapter.jd index 194e94b403040..033450f159a68 100644 --- a/docs/html/training/sync-adapters/running-sync-adapter.jd +++ b/docs/html/training/sync-adapters/running-sync-adapter.jd @@ -11,7 +11,6 @@ trainingnavtop=true
- When a network connection is available, the Android system sends out a message - every few seconds to keep the device's TCP/IP connection open. This message also goes to - the {@link android.content.ContentResolver} of each app. By calling - {@link android.content.ContentResolver#setSyncAutomatically setSyncAutomatically()}, - you can run the sync adapter whenever the {@link android.content.ContentResolver} - receives the message. -
-- By scheduling your sync adapter to run when the network message is sent, you ensure that your - sync adapter is always scheduled to run while the network is available. Use this option if you - don't have to force a data transfer in response to data changes, but you do want to ensure - your data is regularly updated. Similarly, you can use this option if you don't want a fixed - schedule for your sync adapter, but you do want it to run frequently. -
-- Since the method - {@link android.content.ContentResolver#setSyncAutomatically setSyncAutomatically()} - doesn't disable {@link android.content.ContentResolver#addPeriodicSync addPeriodicSync()}, your - sync adapter may be triggered repeatedly in a short period of time. If you do want to run - your sync adapter periodically on a regular schedule, you should disable - {@link android.content.ContentResolver#setSyncAutomatically setSyncAutomatically()}. -
-- The following code snippet shows you how to configure your - {@link android.content.ContentResolver} to run your sync adapter in response to a network - message: -
-
-public class MainActivity extends FragmentActivity {
- ...
- // Constants
- // Content provider authority
- public static final String AUTHORITY = "com.example.android.datasync.provider";
- // Account
- public static final String ACCOUNT = "default_account";
- // Global variables
- // A content resolver for accessing the provider
- ContentResolver mResolver;
- ...
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- ...
- // Get the content resolver for your app
- mResolver = getContentResolver();
- // Turn on automatic syncing for the default account and authority
- mResolver.setSyncAutomatically(ACCOUNT, AUTHORITY, true);
- ...
- }
- ...
-}
-
You can run your sync adapter periodically by setting a period of time to wait between runs,