• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java PeriodicSync类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中android.content.PeriodicSync的典型用法代码示例。如果您正苦于以下问题:Java PeriodicSync类的具体用法?Java PeriodicSync怎么用?Java PeriodicSync使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



PeriodicSync类属于android.content包,在下文中一共展示了PeriodicSync类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: a

import android.content.PeriodicSync; //导入依赖的package包/类
private static void a(Context paramContext, Account paramAccount)
{
  String str = paramAccount.name;
  long l = Math.max(a, ((hyi)mbb.a(paramContext, hyi.class)).c(aun.b, str).longValue());
  Iterator localIterator = ContentResolver.getPeriodicSyncs(paramAccount, "com.google.android.apps.photos.GooglePhotoDownsyncProvider").iterator();
  int i = 0;
  if (localIterator.hasNext())
  {
    PeriodicSync localPeriodicSync = (PeriodicSync)localIterator.next();
    if (localPeriodicSync.period == l) {}
    for (int j = 1;; j = 0)
    {
      if (j == 0) {
        ContentResolver.removePeriodicSync(paramAccount, "com.google.android.apps.photos.GooglePhotoDownsyncProvider", localPeriodicSync.extras);
      }
      i |= j;
      break;
    }
  }
  if (i == 0)
  {
    Bundle localBundle = new Bundle();
    localBundle.putBoolean("sync_periodic", true);
    ContentResolver.addPeriodicSync(paramAccount, "com.google.android.apps.photos.GooglePhotoDownsyncProvider", localBundle, l);
  }
}
 
开发者ID:ChiangC,项目名称:FMTech,代码行数:27,代码来源:GooglePhotoDownsyncService.java


示例2: periodicSyncExists

import android.content.PeriodicSync; //导入依赖的package包/类
/**
 * Test if periodic sync is already configured
 * @param intervalInMinute interval in minute
 * @return true if already exists
 */
private boolean periodicSyncExists( int intervalInMinute ) {
    boolean exists = false;
    long syncInSecond = intervalInMinute * SECONDS_PER_MINUTE;
    List<PeriodicSync> periodicSyncs = ContentResolver.getPeriodicSyncs(mAccount, mAuthority);
    if ( periodicSyncs != null && !periodicSyncs.isEmpty()) {
        for( PeriodicSync periodicSync : periodicSyncs ) {
            if (periodicSync.period == syncInSecond) {
                exists = true ;
            }
        }
    }
    return exists;
}
 
开发者ID:alessandrogurgel,项目名称:pedefacil,代码行数:19,代码来源:AbstractSyncHelper.java


示例3: addPeriodicSync

import android.content.PeriodicSync; //导入依赖的package包/类
@Implementation
public static void addPeriodicSync(Account account, String authority, Bundle extras,
                   long pollFrequency) {

  validateSyncExtrasBundle(extras);
  getStatus(account, authority, true).syncs.add(new PeriodicSync(account, authority, extras, pollFrequency));
}
 
开发者ID:qx,项目名称:FullRobolectricTestSample,代码行数:8,代码来源:ShadowContentResolver.java


示例4: shouldGetPeriodSyncs

import android.content.PeriodicSync; //导入依赖的package包/类
@Test
public void shouldGetPeriodSyncs() throws Exception {
  assertThat(ContentResolver.getPeriodicSyncs(a, AUTHORITY).size()).isEqualTo(0);
  ContentResolver.addPeriodicSync(a, AUTHORITY, new Bundle(), 6000l);

  List<PeriodicSync> syncs = ContentResolver.getPeriodicSyncs(a, AUTHORITY);
  assertThat(syncs.size()).isEqualTo(1);

  PeriodicSync first = syncs.get(0);
  assertThat(first.account).isEqualTo(a);
  assertThat(first.authority).isEqualTo(AUTHORITY);
  assertThat(first.period).isEqualTo(6000l);
  assertNotNull(first.extras);
}
 
开发者ID:qx,项目名称:FullRobolectricTestSample,代码行数:15,代码来源:ContentResolverTest.java


示例5: createAccount

import android.content.PeriodicSync; //导入依赖的package包/类
/**
 * Create a new Account and activate the automatic sync
 * 
 * @param account
 *            null is not allowed
 * @param accountManager
 *            null is not allowed
 * @param password
 *            null is not allowed
 */
public static boolean createAccount(Context context, final Account account,
		AccountManager accountManager, String password) {
	boolean added = accountManager.addAccountExplicitly(account, password,
			null);
	if (added) {
		List<PeriodicSync> syncs = ContentResolver.getPeriodicSyncs(
				account, ContactsContract.AUTHORITY);
		if (syncs != null) {
			// Remove default syncs.
			for (PeriodicSync periodicSync : syncs) {
				ContentResolver.removePeriodicSync(account,
						ContactsContract.AUTHORITY, periodicSync.extras);
			}
		}
		SharedPreferences settings = PreferenceManager
				.getDefaultSharedPreferences(context);
		int synctime;
		try {
			synctime = settings.getInt("pref_synctime",
					DEFAULT_SYNCINTERVAL);
		} catch (ClassCastException e) {
			LogHelper.logI(TAG, "Invalid SyncTime-Settingvalue", e);
			synctime = DEFAULT_SYNCINTERVAL;
		}
		if (synctime != 0) {
			addPeriodicSync(ContactsContract.AUTHORITY, Bundle.EMPTY,
					synctime, context);
		}

		// Set contacts sync for this account.
		ContentResolver.setSyncAutomatically(account,
				ContactsContract.AUTHORITY, true);
	} else {
		LogHelper.logI(TAG, "Account " + account.name
				+ " is already available.");
	}
	return added;
}
 
开发者ID:mgrieder,项目名称:ntsync-android,代码行数:49,代码来源:SyncUtils.java


示例6: applySyncInterval

import android.content.PeriodicSync; //导入依赖的package包/类
public static void applySyncInterval(Context context) {
    Account mAccount = AppUtils.getAccount(context);

    if (mAccount != null) {
        List<PeriodicSync> syncs = ContentResolver.getPeriodicSyncs(
                mAccount, CalendarContractWrapper.AUTHORITY());
        for (PeriodicSync sync : syncs) {
            Log.d(TAG, "old sync: " + sync.period);
        }

        // Inform the system that this account supports sync
        // ContentResolver.setIsSyncable(mAccount,
        // CalendarContractWrapper.AUTHORITY(), 1);

        // Remove old sync periode
        ContentResolver.removePeriodicSync(mAccount,
                CalendarContractWrapper.AUTHORITY(), new Bundle());
        ContentResolver.removePeriodicSync(mAccount,
                KusssContentContract.AUTHORITY, new Bundle());

        // Turn on periodic syncing
        int interval = getSyncInterval(context);

        ContentResolver.addPeriodicSync(mAccount,
                CalendarContractWrapper.AUTHORITY(), new Bundle(),
                60 * 60 * interval);
        ContentResolver.addPeriodicSync(mAccount,
                KusssContentContract.AUTHORITY, new Bundle(),
                60 * 60 * interval);
    }
    AppUtils.updateSyncAlarm(context, true);
}
 
开发者ID:marunjar,项目名称:anewjkuapp,代码行数:33,代码来源:PreferenceWrapper.java


示例7: onItemSelected

import android.content.PeriodicSync; //导入依赖的package包/类
@Override
public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) {
    ((TextView) this.accountSpinner.getSelectedView()).setBackgroundColor(0xFFB6B6B6);
    Account account = Listactivity.accounts[pos];
    // Check periodic sync. If set to 86400 (once a day), set it to 900 (15 minutes)
    // this is due to bad upgrade to v4 which handles offline mode and syncing
    // Remove this code after V4.0 if version no more used
    List<PeriodicSync> currentSyncs = ContentResolver.getPeriodicSyncs (account, AUTHORITY);
    for (PeriodicSync onesync : currentSyncs) {
        if (onesync.period == 86400) {
            ContentResolver.setIsSyncable(account, AUTHORITY, 1);
            ContentResolver.setSyncAutomatically(account, AUTHORITY, true);
            ContentResolver.addPeriodicSync(account, AUTHORITY, new Bundle(), 60);
            Toast.makeText(getApplicationContext(), "Recreating this account is recommended to manage sync interval. Set to 15 minutes in the meantime",
                    Toast.LENGTH_LONG).show();
        }
    }
    // End of code
    Listactivity.imapNotes2Account.SetAccountname(account.name);
    Listactivity.imapNotes2Account.SetUsername(Listactivity.accountManager.getUserData (account, "username"));
    String pwd = Listactivity.accountManager.getPassword(account);
    Listactivity.imapNotes2Account.SetPassword(pwd);
    Listactivity.imapNotes2Account.SetServer(Listactivity.accountManager.getUserData (account, "server"));
    Listactivity.imapNotes2Account.SetPortnum(Listactivity.accountManager.getUserData (account, "portnum"));
    Listactivity.imapNotes2Account.SetSecurity(Listactivity.accountManager.getUserData (account, "security"));
    Listactivity.imapNotes2Account.SetUsesticky(accountManager.getUserData (account, "usesticky"));
    Listactivity.imapNotes2Account.SetSyncinterval(Listactivity.accountManager.getUserData (account, "syncinterval"));
    Listactivity.imapNotes2Account.SetaccountHasChanged();
    Listactivity.imapNotes2Account.SetAccount(account);
    this.RefreshList();
}
 
开发者ID:nbenm,项目名称:ImapNote2,代码行数:32,代码来源:Listactivity.java


示例8: periodicSyncExists

import android.content.PeriodicSync; //导入依赖的package包/类
/**
 * Test if periodic sync is already configured
 *
 * @param intervalInMinute interval in minute
 * @return true if already exists
 */
private boolean periodicSyncExists(int intervalInMinute) {
    boolean exists = false;
    long syncInSecond = intervalInMinute * SECONDS_PER_MINUTE;
    List<PeriodicSync> periodicSyncs = ContentResolver.getPeriodicSyncs(mAccount, mAuthority);
    if (periodicSyncs != null && !periodicSyncs.isEmpty()) {
        for (PeriodicSync periodicSync : periodicSyncs) {
            if (periodicSync.period == syncInSecond) {
                exists = true;
            }
        }
    }
    return exists;
}
 
开发者ID:Michenux,项目名称:YourAppIdea,代码行数:20,代码来源:AbstractSyncHelper.java


示例9: getPeriodicSyncs

import android.content.PeriodicSync; //导入依赖的package包/类
@Implementation
public static List<PeriodicSync> getPeriodicSyncs(Account account, String authority) {
  return getStatus(account, authority, true).syncs;
}
 
开发者ID:qx,项目名称:FullRobolectricTestSample,代码行数:5,代码来源:ShadowContentResolver.java


示例10: getPeriodicSyncs

import android.content.PeriodicSync; //导入依赖的package包/类
private List<PeriodicSync> getPeriodicSyncs(User user) {
    Account account = new Account(user.getUsername(), syncAccountType);
    return ShadowContentResolver.getPeriodicSyncs(account, syncContentAuthority);
}
 
开发者ID:clintonhealthaccess,项目名称:chailmis-android,代码行数:5,代码来源:SyncManagerTest.java



注:本文中的android.content.PeriodicSync类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java DroppedMessageMetrics类代码示例发布时间:2022-05-22
下一篇:
Java Provider类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap