From cbcd99d0934ffda2f295af96e24568ec0750aedb Mon Sep 17 00:00:00 2001 From: Kevin Hufnagle Date: Tue, 15 Mar 2016 20:00:31 -0700 Subject: [PATCH] docs: Removed misleading sync adapter section. Removed section "Run the Sync Adapter After a Network Message," as several members of DevRel believe that the explanation and code sample were too misleading. Also removed related TOC entry and "dictionary entry" (within the user-friendly list of options for sync adapters) at the end of the introductory section for this topic. Bug: 19718330 Change-Id: I1cd2c2e5253653f670c62be95ab50ab626d26a56 --- .../sync-adapters/running-sync-adapter.jd | 64 ------------------- 1 file changed, 64 deletions(-) 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
  1. Run the Sync Adapter When Server Data Changes
  2. Run the Sync Adapter When Content Provider Data Changes
  3. -
  4. Run the Sync Adapter After a Network Message
  5. Run the Sync Adapter Periodically
  6. Run the Sync Adapter On Demand
@@ -68,15 +67,6 @@ trainingnavtop=true implement if you actually store data in your content provider. If you're using a stub content provider, detecting data changes may be more difficult. -
- When the system sends out a network message -
-
- Run a sync adapter when the Android system sends out a network message that keeps the - TCP/IP connection open; this message is a basic part of the networking framework. Using - this option is one way to run the sync adapter automatically. Consider using it in - conjunction with interval-based sync adapter runs. -
At regular intervals
@@ -283,60 +273,6 @@ public class MainActivity extends FragmentActivity { ... } -

Run the Sync Adapter After a Network Message

-

- 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);
-        ...
-    }
-    ...
-}
-

Run the Sync Adapter Periodically

You can run your sync adapter periodically by setting a period of time to wait between runs,