我已实施public class CustomAdapter : BaseAdapter<Devices>
{
private ObservableCollection<Devices> _devices;
private Activity _context;
public CustomAdapter(Activity context, ObservableCollection<Devices> devices) : base()
{
_context = context;
_devices = devices;
}
public override long GetItemId(int position)
{
return position;
}
public override View GetView(int position, View convertView, ViewGroup parent)
{
var device = _devices[position];
View view = convertView;
if (view == null)
view = ((Activity)_context).LayoutInflater.Inflate(Resource.Layout.listView, null);
view.FindViewById<TextView>(Resource.Id.textName).Text = device.Name;
view.FindViewById<TextView>(Resource.Id.textAddress).Text = device.Address;
return view;
}
public override int Count
{
get { return _devices.Count; }
}
public override Devices this[int position]
{
get { return _devices[position]; }
}
}
,同步频率为10秒。但在运行应用程序时,此同步频率会自动更新为900秒。
帐户创建代码:
SyncAdapter
记录跟踪:
public static void createSyncAccount(Context c) {
boolean created = false;
Account account = getAccount();
AccountManager manager = (AccountManager)c.getSystemService(Context.ACCOUNT_SERVICE);
if (manager != null && manager.addAccountExplicitly(account, null, null)) {
final String AUTHORITY = UserIntakeContract.CONTENT_AUTHORITY;
final long SYNC_FREQUENCY = 10; // (seconds)
ContentResolver.setIsSyncable(account, AUTHORITY, 1);
ContentResolver.setSyncAutomatically(account, AUTHORITY, true);
ContentResolver.addPeriodicSync(account, AUTHORITY, new Bundle(), SYNC_FREQUENCY);
created = true;
}
if (created) {
SyncAdapter.performSync();
}
}
但我无法找到任何资源或文件说明最低轮询频率为15分钟(900秒)。
任何人都可以提供一些真实的资源或文档或解释吗?
答案 0 :(得分:0)
您是否查看了“ContentResolver.addPeriodicSync”的文档?有一个民意调查频率文档,描述如下: long:执行同步的频率,以秒为单位。最低值为1小时。 也许由于这种强制执行,这种变化正在发生。
答案 1 :(得分:0)
看起来您正试图将时间段设置为超出限制。
看完来源:
可设置的最短时间段因版本而异。