android - Scheduled sync adapter runs every 30 seconds -
i use sync adapters in application sync changes server periodically. no matter value put in pollfrequency sync runs every 30 seconds.
i checked on forum , tried changes suggested in replies , pass 'false' synctonetwork parameter when raise notifychange on contentresolver.
on going through training again in detail, stumbled upon difference.
on google developer site -> training section sync adapters training see addperiodicsync -> pollfrequency parameter passed in milliseconds
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"; // sync interval constants public static final long milliseconds_per_second = 1000l; public static final long seconds_per_minute = 60l; public static final long sync_interval_in_minutes = 60l; //this line i'm referring public static final long sync_interval = sync_interval_in_minutes * seconds_per_minute * milliseconds_per_second; // global variables // content resolver accessing provider contentresolver mresolver; ... @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); ... // content resolver app mresolver = getcontentresolver(); /* * turn on periodic syncing */ contentresolver.addperiodicsync( account, authority, null, sync_interval); ... } ... }
on api reference api reference pollfrequency mentioned in seconds. expected unit pollfrequency, milliseconds or seconds? appreciated.
you should add contentresolver.setmastersyncautomatically(true); code. without setsyncautomatically ignored.
read documentation here.
Comments
Post a Comment