当前位置: 首页>>代码示例>>Java>>正文


Java AccountUtils.getActiveAccountName方法代码示例

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


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

示例1: 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

示例2: onCreate

import com.google.samples.apps.iosched.util.AccountUtils; //导入方法依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    final String chosenAccountName = AccountUtils.getActiveAccountName(getActivity());
    mPlusClient = new PlusClient.Builder(getActivity(), this, this)
            .clearScopes()
            .setAccountName(chosenAccountName)
            .build();

    final Intent intent = BaseActivity.fragmentArgumentsToIntent(getArguments());
    mSessionUri = intent.getData();

    if (mSessionUri == null) {
        return;
    }

    mSessionId = ScheduleContract.Sessions.getSessionId(mSessionUri);

    mVariableHeightHeader = intent.getBooleanExtra(EXTRA_VARIABLE_HEIGHT_HEADER, false);

    LoaderManager manager = getLoaderManager();
    manager.restartLoader(0, null, this);

    setHasOptionsMenu(true);
}
 
开发者ID:gdg-bh,项目名称:AppDevFestSudeste2015,代码行数:26,代码来源:SessionFeedbackFragment.java

示例3: getGoogleApiClient

import com.google.samples.apps.iosched.util.AccountUtils; //导入方法依赖的package包/类
/**
 * Gets the GoogleApliClient owned by this async task.
 */
protected GoogleApiClient getGoogleApiClient() {
    String currentAccountName = AccountUtils.getActiveAccountName(mContext);
    if (lastUsedAccountName != null &&
            !lastUsedAccountName.equals(currentAccountName)) {
        if (mClient != null && mClient.isConnected()) {
            mClient.disconnect();
        }
        mClient = null;
        lastUsedAccountName = currentAccountName;
    }
    if (mClient == null) {
        GoogleApiClient.Builder builder = new GoogleApiClient.Builder(mContext)
                .addApi(Drive.API)
                .setAccountName(currentAccountName)
                .addScope(Drive.SCOPE_APPFOLDER);
        mClient = builder.build();
    }
    mClient.connect();
    return mClient;
}
 
开发者ID:gdg-bh,项目名称:AppDevFestSudeste2015,代码行数:24,代码来源:ApiClientAsyncTask.java

示例4: 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(true);
        } else {
            // this is a request to sync everything
            ContentResolver.requestSync(account, ScheduleContract.CONTENT_AUTHORITY, new Bundle());
        }
    }
}
 
开发者ID:google,项目名称:iosched,代码行数:19,代码来源:TriggerSyncReceiver.java

示例5: getCalendarId

import com.google.samples.apps.iosched.util.AccountUtils; //导入方法依赖的package包/类
/**
 * Gets the currently-logged in user's Google Calendar, or the Google Calendar for the user
 * specified in the given intent's {@link #EXTRA_ACCOUNT_NAME}.
 */
private long getCalendarId(Intent intent) {
    final String accountName;
    if (intent != null && intent.hasExtra(EXTRA_ACCOUNT_NAME)) {
        accountName = intent.getStringExtra(EXTRA_ACCOUNT_NAME);
    } else {
        accountName = AccountUtils.getActiveAccountName(this);
    }

    if (TextUtils.isEmpty(accountName)) {
        return INVALID_CALENDAR_ID;
    }

    // TODO: The calendar ID should be stored in shared settings_prefs upon choosing an account.
    Cursor calendarsCursor = getContentResolver().query(
            CalendarContract.Calendars.CONTENT_URI,
            new String[]{"_id"},
            // TODO: What if the calendar is not displayed or not sync'd?
            "account_name = ownerAccount and account_name = ?",
            new String[]{accountName},
            null);

    long calendarId = INVALID_CALENDAR_ID;
    if (calendarsCursor != null && calendarsCursor.moveToFirst()) {
        calendarId = calendarsCursor.getLong(0);
        calendarsCursor.close();
    }

    return calendarId;
}
 
开发者ID:dreaminglion,项目名称:iosched-reader,代码行数:34,代码来源:SessionCalendarService.java

示例6: getCurrentAccountName

import com.google.samples.apps.iosched.util.AccountUtils; //导入方法依赖的package包/类
private String getCurrentAccountName(Uri uri, boolean sanitize) {
    String accountName = ScheduleContractHelper.getOverrideAccountName(uri);
    if (accountName == null) {
        accountName = AccountUtils.getActiveAccountName(getContext());
    }
    if (sanitize) {
        // sanitize accountName when concatenating (http://xkcd.com/327/)
        accountName = (accountName != null) ? accountName.replace("'", "''") : null;
    }
    return accountName;
}
 
开发者ID:dreaminglion,项目名称:iosched-reader,代码行数:12,代码来源:ScheduleProvider.java

示例7: getCalendarId

import com.google.samples.apps.iosched.util.AccountUtils; //导入方法依赖的package包/类
/**
 * Gets the currently-logged in user's Google Calendar, or the Google Calendar for the user
 * specified in the given intent's {@link #EXTRA_ACCOUNT_NAME}.
 */
private long getCalendarId(Intent intent) {
    final String accountName;
    if (intent != null && intent.hasExtra(EXTRA_ACCOUNT_NAME)) {
        accountName = intent.getStringExtra(EXTRA_ACCOUNT_NAME);
    } else {
        accountName = AccountUtils.getActiveAccountName(this);
    }

    if (TextUtils.isEmpty(accountName)) {
        return INVALID_CALENDAR_ID;
    }

    // TODO: The calendar ID should be stored in shared preferences upon choosing an account.
    Cursor calendarsCursor = getContentResolver().query(
            CalendarContract.Calendars.CONTENT_URI,
            new String[]{"_id"},
            // TODO: What if the calendar is not displayed or not sync'd?
            "account_name = ownerAccount and account_name = ?",
            new String[]{accountName},
            null);

    long calendarId = INVALID_CALENDAR_ID;
    if (calendarsCursor != null && calendarsCursor.moveToFirst()) {
        calendarId = calendarsCursor.getLong(0);
        calendarsCursor.close();
    }

    return calendarId;
}
 
开发者ID:gdg-bh,项目名称:AppDevFestSudeste2015,代码行数:34,代码来源:SessionCalendarService.java

示例8: getCurrentAccountName

import com.google.samples.apps.iosched.util.AccountUtils; //导入方法依赖的package包/类
private String getCurrentAccountName(Uri uri, boolean sanitize) {
    String accountName = ScheduleContract.getOverrideAccountName(uri);
    if (accountName == null) {
        accountName = AccountUtils.getActiveAccountName(getContext());
    }
    if (sanitize) {
        // sanitize accountName when concatenating (http://xkcd.com/327/)
        accountName = (accountName != null) ? accountName.replace("'", "''") : null;
    }
    return accountName;
}
 
开发者ID:gdg-bh,项目名称:AppDevFestSudeste2015,代码行数:12,代码来源:ScheduleProvider.java

示例9: getCalendarId

import com.google.samples.apps.iosched.util.AccountUtils; //导入方法依赖的package包/类
/**
 * Gets the currently-logged in user's Google Calendar, or the Google Calendar for the user
 * specified in the given intent's {@link #EXTRA_ACCOUNT_NAME}.
 */
private long getCalendarId(Intent intent) {
    final String accountName;
    if (intent != null && intent.hasExtra(EXTRA_ACCOUNT_NAME)) {
        accountName = intent.getStringExtra(EXTRA_ACCOUNT_NAME);
    } else {
        accountName = AccountUtils.getActiveAccountName(this);
    }

    if (TextUtils.isEmpty(accountName) || !permissionsAlreadyGranted()) {
        return INVALID_CALENDAR_ID;
    }

    // TODO: The calendar ID should be stored in shared settings_prefs upon choosing an account.
    @SuppressWarnings("MissingPermission") Cursor calendarsCursor = getContentResolver().query(
            CalendarContract.Calendars.CONTENT_URI,
            new String[]{"_id"},
            // TODO: What if the calendar is not displayed or not sync'd?
            "account_name = ownerAccount and account_name = ?",
            new String[]{accountName},
            null);

    long calendarId = INVALID_CALENDAR_ID;
    if (calendarsCursor != null && calendarsCursor.moveToFirst()) {
        calendarId = calendarsCursor.getLong(0);
        calendarsCursor.close();
    }

    return calendarId;
}
 
开发者ID:google,项目名称:iosched,代码行数:34,代码来源:SessionCalendarService.java

示例10: doUserDataSync

import com.google.samples.apps.iosched.util.AccountUtils; //导入方法依赖的package包/类
/**
 * Checks if there are changes on User's Data to sync with/from remote AppData folder.
 *
 * @return Whether or not data was changed.
 * @throws IOException if there is a problem uploading the data.
 */
private boolean doUserDataSync(SyncResult syncResult) throws IOException {
    if (!ConnectivityUtils.isConnected(mContext)) {
        LOGD(TAG, "Not attempting userdata sync because device is OFFLINE");
        return false;
    }

    String accountName = AccountUtils.getActiveAccountName(mContext);
    if (TextUtils.isEmpty(accountName)) {
        LOGD(TAG, "Not attempting userdata sync because user is not signed in");
        return false;
    }

    LOGD(TAG, "Starting user data sync.");

    AbstractUserDataSyncHelper helper = UserDataSyncHelperFactory.buildSyncHelper(
            mContext, accountName);
    boolean modified = helper.sync();

    if (modified) {
        // Schedule notifications for the starred sessions.
        Intent scheduleIntent = new Intent(
                SessionAlarmService.ACTION_SCHEDULE_ALL_STARRED_BLOCKS,
                null, mContext, SessionAlarmService.class);
        mContext.startService(scheduleIntent);
    }
    syncResult.stats.numIoExceptions += helper.getIoExcpetions();
    return modified;
}
 
开发者ID:google,项目名称:iosched,代码行数:35,代码来源:SyncHelper.java

示例11: buildMyScheduleUri

import com.google.samples.apps.iosched.util.AccountUtils; //导入方法依赖的package包/类
public static Uri buildMyScheduleUri(Context context, String accountName) {
    if (accountName == null) {
        accountName = AccountUtils.getActiveAccountName(context);
    }
    return addOverrideAccountName(CONTENT_URI, accountName);
}
 
开发者ID:gdg-bh,项目名称:AppDevFestSudeste2015,代码行数:7,代码来源:ScheduleContract.java

示例12: updateLocal

import com.google.samples.apps.iosched.util.AccountUtils; //导入方法依赖的package包/类
private void updateLocal() {
    String accountName = AccountUtils.getActiveAccountName(mContext);
    LocalUserDataHelper.setLocalUserData(mContext, mReconciledUserDataModel, accountName);
}
 
开发者ID:google,项目名称:iosched,代码行数:5,代码来源:UserDataSyncHelper.java

示例13: clearUserDataOnSignOut

import com.google.samples.apps.iosched.util.AccountUtils; //导入方法依赖的package包/类
public static void clearUserDataOnSignOut(final Context context) {
    String accountName = AccountUtils.getActiveAccountName(context);
    ClearDataAsyncHandler handler = new ClearDataAsyncHandler(context, accountName);
    handler.clearUserData();
}
 
开发者ID:google,项目名称:iosched,代码行数:6,代码来源:LocalUserDataHelper.java


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