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

Java AccountUtils类代码示例

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

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



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

示例1: run

import com.google.samples.apps.iosched.util.AccountUtils; //导入依赖的package包/类
@Override
public void run(final Context context, final Callback callback) {
    ConferenceDataHandler.resetDataTimestamp(context);
    final Bundle bundle = new Bundle();
    bundle.putBoolean(ContentResolver.SYNC_EXTRAS_MANUAL, true);
    new AsyncTask<Context, Void, Void>() {
        @Override
        protected Void doInBackground(Context... contexts) {
            Account account = AccountUtils.getActiveAccount(context);
            if (account == null) {
                callback.done(false, "Cannot sync if there is no active account.");
            } else {
                new SyncHelper(contexts[0]).performSync(new SyncResult(),
                  AccountUtils.getActiveAccount(context), bundle);
            }
          return null;
        }
    }.execute(context);
}
 
开发者ID:dreaminglion,项目名称:iosched-reader,代码行数:20,代码来源:ForceSyncNowAction.java


示例2: run

import com.google.samples.apps.iosched.util.AccountUtils; //导入依赖的package包/类
@Override
public void run(final Context context, final Callback callback) {
    new AsyncTask<Context, Void, Void>() {
        @Override
        protected Void doInBackground(Context... params) {
            final AbstractUserDataSyncHelper syncer = UserDataSyncHelperFactory.buildSyncHelper(
                    context, AccountUtils.getActiveAccountName(context));
            syncer.sync();
            return null;
        }

        @Override
        protected void onPostExecute(Void aVoid) {
            callback.done(true, "Sync done");
        }
    }.execute(context);

}
 
开发者ID:dreaminglion,项目名称:iosched-reader,代码行数:19,代码来源:ForceAppDataSyncNowAction.java


示例3: onResume

import com.google.samples.apps.iosched.util.AccountUtils; //导入依赖的package包/类
@Override
protected void onResume() {
    super.onResume();

    // Perform one-time bootstrap setup, if needed
    DataBootstrapService.startDataBootstrapIfNecessary(this);

    // Check to ensure a Google Account is active for the app. Placing the check here ensures
    // it is run again in the case where a Google Account wasn't present on the device and a
    // picker had to be started.
    if (!AccountUtils.enforceActiveGoogleAccount(this, SELECT_GOOGLE_ACCOUNT_RESULT)) {
        LOGD(TAG, "EnforceActiveGoogleAccount returned false");
        return;
    }

    // Watch for sync state changes
    mSyncStatusObserver.onStatusChanged(0);
    final int mask = ContentResolver.SYNC_OBSERVER_TYPE_PENDING |
            ContentResolver.SYNC_OBSERVER_TYPE_ACTIVE;
    mSyncObserverHandle = ContentResolver.addStatusChangeListener(mask, mSyncStatusObserver);

    startLoginProcess();
}
 
开发者ID:dreaminglion,项目名称:iosched-reader,代码行数:24,代码来源:BaseActivity.java


示例4: onActivityResult

import com.google.samples.apps.iosched.util.AccountUtils; //导入依赖的package包/类
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    // Handle the select {@code startActivityForResult} from
    // {@code enforceActiveGoogleAccount()} when a Google Account wasn't present on the device.
    if (requestCode == SELECT_GOOGLE_ACCOUNT_RESULT) {
        if (resultCode == RESULT_OK) {
            // Set selected GoogleAccount as active.
            String accountName = data.getStringExtra(AccountManager.KEY_ACCOUNT_NAME);
            AccountUtils.setActiveAccount(this, accountName);
            onAuthSuccess(accountName, true);
        } else {
            LOGW(TAG, "A Google Account is required to use this application.");
            // This application requires a Google Account to be selected.
            finish();
        }
        return;
    }

    if (mLoginAndAuthHelper == null || !mLoginAndAuthHelper.onActivityResult(requestCode,
            resultCode, data)) {
        super.onActivityResult(requestCode, resultCode, data);
    }
}
 
开发者ID:dreaminglion,项目名称:iosched-reader,代码行数:24,代码来源:BaseActivity.java


示例5: onStatusChanged

import com.google.samples.apps.iosched.util.AccountUtils; //导入依赖的package包/类
@Override
public void onStatusChanged(int which) {
    runOnUiThread(new Runnable() {
        @Override
        public void run() {
            String accountName = AccountUtils.getActiveAccountName(BaseActivity.this);
            if (TextUtils.isEmpty(accountName)) {
                onRefreshingStateChanged(false);
                mManualSyncRequest = false;
                return;
            }

            Account account = new Account(accountName, GoogleAuthUtil.GOOGLE_ACCOUNT_TYPE);
            boolean syncActive = ContentResolver.isSyncActive(
                    account, ScheduleContract.CONTENT_AUTHORITY);
            boolean syncPending = ContentResolver.isSyncPending(
                    account, ScheduleContract.CONTENT_AUTHORITY);
            if (!syncActive && !syncPending) {
                mManualSyncRequest = false;
            }
            onRefreshingStateChanged(syncActive || mManualSyncRequest);
        }
    });
}
 
开发者ID:dreaminglion,项目名称:iosched-reader,代码行数:25,代码来源:BaseActivity.java


示例6: dump

import com.google.samples.apps.iosched.util.AccountUtils; //导入依赖的package包/类
/**
 * Providing important state information to be included in bug reports.
 *
 * !!! Remember !!! Any important data logged to {@code writer} shouldn't contain personally
 * identifiable information as it can be seen in bugreports.
 */
@Override
public void dump(FileDescriptor fd, PrintWriter writer, String[] args) {
    Context context = getContext();

    // Using try/catch block in case there are issues retrieving information to log.
    try {
        // Calling append in multiple calls is typically better than creating net new strings to
        // pass to method invocations.
        writer.print("Last sync attempted: ");
        writer.println(new java.util.Date(SettingsUtils.getLastSyncAttemptedTime(context)));
        writer.print("Last sync successful: ");
        writer.println(new java.util.Date(SettingsUtils.getLastSyncSucceededTime(context)));
        writer.print("Current sync interval: ");
        writer.println(SettingsUtils.getCurSyncInterval(context));
        writer.print("Is an account active: ");
        writer.println(AccountUtils.hasActiveAccount(context));
        boolean canGetAuthToken = !TextUtils.isEmpty(AccountUtils.getAuthToken(context));
        writer.print("Can an auth token be retrieved: ");
        writer.println(canGetAuthToken);

    } catch (Exception exception) {
        writer.append("Exception while dumping state: ");
        exception.printStackTrace(writer);
    }
}
 
开发者ID:dreaminglion,项目名称:iosched-reader,代码行数:32,代码来源:ScheduleProvider.java


示例7: onReceive

import com.google.samples.apps.iosched.util.AccountUtils; //导入依赖的package包/类
@Override
public void onReceive(final Context context, Intent widgetIntent) {
    final String action = widgetIntent.getAction();

    if (REFRESH_ACTION.equals(action)) {
        LOGD(TAG, "received REFRESH_ACTION from widget");
        final boolean shouldSync = widgetIntent.getBooleanExtra(EXTRA_PERFORM_SYNC, false);

        // Trigger sync
        Account chosenAccount = AccountUtils.getActiveAccount(context);
        if (shouldSync && chosenAccount != null) {
            SyncHelper.requestManualSync(chosenAccount);
        }

        // Notify the widget that the list view needs to be updated.
        final AppWidgetManager mgr = AppWidgetManager.getInstance(context);
        final ComponentName cn = new ComponentName(context, ScheduleWidgetProvider.class);
        mgr.notifyAppWidgetViewDataChanged(mgr.getAppWidgetIds(cn),
                R.id.widget_schedule_list);

    }
    super.onReceive(context, widgetIntent);
}
 
开发者ID:dreaminglion,项目名称:iosched-reader,代码行数:24,代码来源:ScheduleWidgetProvider.java


示例8: onReceive

import com.google.samples.apps.iosched.util.AccountUtils; //导入依赖的package包/类
@Override
public void onReceive(Context context, Intent intent) {
    String accountName = AccountUtils.getActiveAccountName(context);
    if (TextUtils.isEmpty(accountName)) {
        return;
    }
    Account account = AccountUtils.getActiveAccount(context);
    if (account != null) {
        if (intent.getBooleanExtra(EXTRA_USER_DATA_SYNC_ONLY, false) ) {
            // this is a request to sync user data only, so do a manual sync right now
            // with the userDataOnly == true.
            SyncHelper.requestManualSync(account, true);
        } else {
            // this is a request to sync everything
            ContentResolver.requestSync(account, ScheduleContract.CONTENT_AUTHORITY, new Bundle());
        }
    }
}
 
开发者ID:dreaminglion,项目名称:iosched-reader,代码行数:19,代码来源:TriggerSyncReceiver.java


示例9: notifyUserDataChanged

import com.google.samples.apps.iosched.util.AccountUtils; //导入依赖的package包/类
/**
 * Request user data sync.
 *
 * @param context Current context
 */
public static void notifyUserDataChanged(final Context context) {
    if (!checkGcmEnabled()) {
        return;
    }

    LOGI(TAG, "Notifying GCM that user data changed");
    String serverUrl = BuildConfig.GCM_SERVER_URL + "/send/self/sync_user";
    try {
        String gcmKey = AccountUtils.getGcmKey(context, AccountUtils.getActiveAccountName(context));
        if (gcmKey != null) {
            post(serverUrl, new HashMap<String, String>(), gcmKey);
        }
    } catch (IOException e) {
        LOGE(TAG, "Unable to notify GCM about user data change", e);
    }
}
 
开发者ID:dreaminglion,项目名称:iosched-reader,代码行数:22,代码来源:ServerUtilities.java


示例10: setRegisteredOnServer

import com.google.samples.apps.iosched.util.AccountUtils; //导入依赖的package包/类
/**
 * Sets whether the device was successfully registered in the server side.
 *
 * @param context Current context
 * @param flag    True if registration was successful, false otherwise
 * @param gcmId    True if registration was successful, false otherwise
 */
private static void setRegisteredOnServer(Context context, boolean flag, String gcmId, String gcmKey) {
    final SharedPreferences prefs = context.getSharedPreferences(
            PREFERENCES, Context.MODE_PRIVATE);
    LOGD(TAG, "Setting registered on server status as: " + flag + ", gcmKey="
            + AccountUtils.sanitizeGcmKey(gcmKey));
    Editor editor = prefs.edit();
    if (flag) {
        editor.putLong(PROPERTY_REGISTERED_TS, new Date().getTime());
        editor.putString(PROPERTY_GCM_KEY, gcmKey == null ? "" : gcmKey);
        editor.putString(PROPERTY_REG_ID, gcmId);
    } else {
        editor.remove(PROPERTY_REG_ID);
    }
    editor.apply();
}
 
开发者ID:dreaminglion,项目名称:iosched-reader,代码行数:23,代码来源:ServerUtilities.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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