本文整理汇总了Java中com.google.samples.apps.iosched.util.AccountUtils.getActiveAccount方法的典型用法代码示例。如果您正苦于以下问题:Java AccountUtils.getActiveAccount方法的具体用法?Java AccountUtils.getActiveAccount怎么用?Java AccountUtils.getActiveAccount使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.samples.apps.iosched.util.AccountUtils
的用法示例。
在下文中一共展示了AccountUtils.getActiveAccount方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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);
}
示例2: 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());
}
}
}
示例3: 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());
}
}
}
示例4: shouldDisplay
import com.google.samples.apps.iosched.util.AccountUtils; //导入方法依赖的package包/类
@Override
public boolean shouldDisplay(Context context) {
Account account = AccountUtils.getActiveAccount(context);
if (account == null) {
return true;
}
return false;
}
示例5: requestDataRefresh
import com.google.samples.apps.iosched.util.AccountUtils; //导入方法依赖的package包/类
protected void requestDataRefresh() {
Account activeAccount = AccountUtils.getActiveAccount(this);
ContentResolver contentResolver = getContentResolver();
if (contentResolver.isSyncActive(activeAccount, ScheduleContract.CONTENT_AUTHORITY)) {
LOGD(TAG, "Ignoring manual sync request because a sync is already in progress.");
return;
}
mManualSyncRequest = true;
LOGD(TAG, "Requesting manual data refresh.");
SyncHelper.requestManualSync(activeAccount);
}
示例6: requestDataRefresh
import com.google.samples.apps.iosched.util.AccountUtils; //导入方法依赖的package包/类
protected void requestDataRefresh() {
android.accounts.Account activeAccount = AccountUtils.getActiveAccount(this);
if (activeAccount == null) {
return;
}
if (ContentResolver.isSyncActive(activeAccount, ScheduleContract.CONTENT_AUTHORITY)) {
LOGD(TAG, "Ignoring manual sync request because a sync is already in progress.");
return;
}
LOGD(TAG, "Requesting manual data refresh.");
SyncHelper.requestManualSync();
}
示例7: setupAccountBox
import com.google.samples.apps.iosched.util.AccountUtils; //导入方法依赖的package包/类
/**
* Sets up the account box. The account box is the area at the top of the nav drawer that
* shows which account the user is logged in as, and lets them switch accounts. It also
* shows the user's Google+ cover photo as background.
*/
private void setupAccountBox() {
mAccountListContainer = (LinearLayout) findViewById(R.id.account_list);
if (mAccountListContainer == null) {
//This activity does not have an account box
return;
}
final View chosenAccountView = findViewById(R.id.chosen_account_view);
Account chosenAccount = AccountUtils.getActiveAccount(this);
if (chosenAccount == null) {
// No account logged in; hide account box
chosenAccountView.setVisibility(View.GONE);
mAccountListContainer.setVisibility(View.GONE);
return;
} else {
chosenAccountView.setVisibility(View.VISIBLE);
mAccountListContainer.setVisibility(View.INVISIBLE);
}
AccountManager am = AccountManager.get(this);
Account[] accountArray = am.getAccountsByType(GoogleAuthUtil.GOOGLE_ACCOUNT_TYPE);
List<Account> accounts = new ArrayList<Account>(Arrays.asList(accountArray));
accounts.remove(chosenAccount);
ImageView coverImageView = (ImageView) chosenAccountView.findViewById(R.id.profile_cover_image);
ImageView profileImageView = (ImageView) chosenAccountView.findViewById(R.id.profile_image);
TextView nameTextView = (TextView) chosenAccountView.findViewById(R.id.profile_name_text);
TextView email = (TextView) chosenAccountView.findViewById(R.id.profile_email_text);
mExpandAccountBoxIndicator = (ImageView) findViewById(R.id.expand_account_box_indicator);
String name = AccountUtils.getPlusName(this);
if (name == null) {
nameTextView.setVisibility(View.GONE);
} else {
nameTextView.setVisibility(View.VISIBLE);
nameTextView.setText(name);
}
String imageUrl = AccountUtils.getPlusImageUrl(this);
if (imageUrl != null) {
mImageLoader.loadImage(imageUrl, profileImageView);
}
String coverImageUrl = AccountUtils.getPlusCoverUrl(this);
if (coverImageUrl != null) {
mImageLoader.loadImage(coverImageUrl, coverImageView);
} else {
coverImageView.setImageResource(R.color.nearby_header_color);
}
email.setText(chosenAccount.name);
if (accounts.isEmpty()) {
// There's only one account on the device, so no need for a switcher.
mExpandAccountBoxIndicator.setVisibility(View.GONE);
mAccountListContainer.setVisibility(View.GONE);
chosenAccountView.setEnabled(false);
return;
}
chosenAccountView.setEnabled(true);
mExpandAccountBoxIndicator.setVisibility(View.VISIBLE);
chosenAccountView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
mAccountBoxExpanded = !mAccountBoxExpanded;
setupAccountBoxToggle();
}
});
setupAccountBoxToggle();
populateAccountList(accounts);
}
示例8: onUpgrade
import com.google.samples.apps.iosched.util.AccountUtils; //导入方法依赖的package包/类
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
LOGD(TAG, "onUpgrade() from " + oldVersion + " to " + newVersion);
// Cancel any sync currently in progress
Account account = AccountUtils.getActiveAccount(mContext);
if (account != null) {
LOGI(TAG, "Cancelling any pending syncs for account");
ContentResolver.cancelSync(account, ScheduleContract.CONTENT_AUTHORITY);
}
// Current DB version. We update this variable as we perform upgrades to reflect
// the current version we are in.
int version = oldVersion;
// Indicates whether the data we currently have should be invalidated as a
// result of the db upgrade. Default is true (invalidate); if we detect that this
// is a trivial DB upgrade, we set this to false.
boolean dataInvalidated = true;
// Check if we can upgrade from release A to release C
if (version == VER_2014_RELEASE_A) {
// release A format can be upgraded to release C format
LOGD(TAG, "Upgrading database from 2014 release A to 2014 release C.");
upgradeAtoC(db);
version = VER_2014_RELEASE_C;
}
LOGD(TAG, "After upgrade logic, at version " + version);
// at this point, we ran out of upgrade logic, so if we are still at the wrong
// version, we have no choice but to delete everything and create everything again.
if (version != CUR_DATABASE_VERSION) {
LOGW(TAG, "Upgrade unsuccessful -- destroying old data during upgrade");
db.execSQL("DROP TRIGGER IF EXISTS " + Triggers.SESSIONS_TAGS_DELETE);
db.execSQL("DROP TRIGGER IF EXISTS " + Triggers.SESSIONS_SPEAKERS_DELETE);
db.execSQL("DROP TRIGGER IF EXISTS " + Triggers.SESSIONS_FEEDBACK_DELETE);
db.execSQL("DROP TRIGGER IF EXISTS " + Triggers.SESSIONS_MY_SCHEDULE_DELETE);
db.execSQL("DROP TRIGGER IF EXISTS " + Triggers.DeprecatedTriggers.SESSIONS_TRACKS_DELETE);
db.execSQL("DROP TABLE IF EXISTS " + Tables.BLOCKS);
db.execSQL("DROP TABLE IF EXISTS " + Tables.ROOMS);
db.execSQL("DROP TABLE IF EXISTS " + Tables.TAGS);
db.execSQL("DROP TABLE IF EXISTS " + Tables.SESSIONS);
db.execSQL("DROP TABLE IF EXISTS " + Tables.SPEAKERS);
db.execSQL("DROP TABLE IF EXISTS " + Tables.MY_SCHEDULE);
db.execSQL("DROP TABLE IF EXISTS " + Tables.SESSIONS_SPEAKERS);
db.execSQL("DROP TABLE IF EXISTS " + Tables.SESSIONS_TAGS);
db.execSQL("DROP TABLE IF EXISTS " + Tables.ANNOUNCEMENTS);
db.execSQL("DROP TABLE IF EXISTS " + Tables.FEEDBACK);
db.execSQL("DROP TABLE IF EXISTS " + Tables.SESSIONS_SEARCH);
db.execSQL("DROP TABLE IF EXISTS " + Tables.SEARCH_SUGGEST);
db.execSQL("DROP TABLE IF EXISTS " + Tables.MAPMARKERS);
db.execSQL("DROP TABLE IF EXISTS " + Tables.MAPTILES);
db.execSQL("DROP TABLE IF EXISTS " + Tables.EXPERTS);
db.execSQL("DROP TABLE IF EXISTS " + Tables.HASHTAGS);
db.execSQL("DROP TABLE IF EXISTS " + Tables.PEOPLE_IVE_MET);
db.execSQL("DROP TABLE IF EXISTS " + Tables.VIDEOS);
db.execSQL("DROP TABLE IF EXISTS " + Tables.PARTNERS);
db.execSQL("DROP TABLE IF EXISTS " + Tables.DeprecatedTables.TRACKS);
db.execSQL("DROP TABLE IF EXISTS " + Tables.DeprecatedTables.SESSIONS_TRACKS);
db.execSQL("DROP TABLE IF EXISTS " + Tables.DeprecatedTables.SANDBOX);
onCreate(db);
version = CUR_DATABASE_VERSION;
}
if (dataInvalidated) {
LOGD(TAG, "Data invalidated; resetting our data timestamp.");
ConferenceDataHandler.resetDataTimestamp(mContext);
if (account != null) {
LOGI(TAG, "DB upgrade complete. Requesting resync.");
SyncHelper.requestManualSync(account);
}
}
}