本文整理汇总了Java中android.accounts.Account类的典型用法代码示例。如果您正苦于以下问题:Java Account类的具体用法?Java Account怎么用?Java Account使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Account类属于android.accounts包,在下文中一共展示了Account类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: invalidateAccessToken
import android.accounts.Account; //导入依赖的package包/类
public void invalidateAccessToken(Account account, Bundle options) throws RemoteException {
Parcel _data = Parcel.obtain();
Parcel _reply = Parcel.obtain();
try {
_data.writeInterfaceToken(Stub.DESCRIPTOR);
if (account != null) {
_data.writeInt(1);
account.writeToParcel(_data, 0);
} else {
_data.writeInt(0);
}
if (options != null) {
_data.writeInt(1);
options.writeToParcel(_data, 0);
} else {
_data.writeInt(0);
}
this.mRemote.transact(4, _data, _reply, 0);
_reply.readException();
} finally {
_reply.recycle();
_data.recycle();
}
}
示例2: onPerformSync
import android.accounts.Account; //导入依赖的package包/类
/**
* Called by the Android system in response to a request to run the sync adapter. The work
* required to read data from the network, parse it, and store it in the content provider
* should be done here. Extending AbstractThreadedSyncAdapter ensures that all methods within SyncAdapter
* run on a background thread. For this reason, blocking I/O and other long-running tasks can be
* run <em>in situ</em>, and you don't have to set up a separate thread for them.
*
* <p>
* <p>This is where we actually perform any work required to perform a sync.
* {@link AbstractThreadedSyncAdapter} guarantees that this will be called on a non-UI thread,
* so it is safe to perform blocking I/O here.
* <p>
*
* <p>The syncResult argument allows you to pass information back to the method that triggered
* the sync.
*/
@Override
public void onPerformSync(Account account, Bundle extras, String authority,
ContentProviderClient provider, SyncResult syncResult) {
// Your code to sync data
// between mobile database and
// the server goes here.
for (int i = 0; i < 15; i++) {
try {
Thread.sleep(1000);
Log.i(TAG, ">>>> sleeping the thread: " + (i + 1));
} catch (InterruptedException e) {
e.printStackTrace();
}
} // end for
// write DB data sanity checks at the end.
}
示例3: invalidateAccessToken
import android.accounts.Account; //导入依赖的package包/类
public void invalidateAccessToken(Account account, Bundle options) throws
RemoteException {
Parcel _data = Parcel.obtain();
Parcel _reply = Parcel.obtain();
try {
_data.writeInterfaceToken(Stub.DESCRIPTOR);
if (account != null) {
_data.writeInt(1);
account.writeToParcel(_data, 0);
} else {
_data.writeInt(0);
}
if (options != null) {
_data.writeInt(1);
options.writeToParcel(_data, 0);
} else {
_data.writeInt(0);
}
this.mRemote.transact(4, _data, _reply, 0);
_reply.readException();
} finally {
_reply.recycle();
_data.recycle();
}
}
示例4: renameAccountInternal
import android.accounts.Account; //导入依赖的package包/类
private Account renameAccountInternal(int userId, Account accountToRename, String newName) {
// TODO: Cancel Notification
synchronized (accountsByUserId) {
VAccount vAccount = getAccount(userId, accountToRename);
if (vAccount != null) {
vAccount.previousName = vAccount.name;
vAccount.name = newName;
serializeAllAccounts();
Account newAccount = new Account(vAccount.name, vAccount.type);
synchronized (authTokenRecords) {
for (AuthTokenRecord record : authTokenRecords) {
if (record.userId == userId && record.account.equals(accountToRename)) {
record.account = newAccount;
}
}
}
sendAccountsChangedBroadcast(userId);
return newAccount;
}
}
return accountToRename;
}
示例5: getAllowableAccountSet
import android.accounts.Account; //导入依赖的package包/类
/**
* Returns a set of whitelisted accounts given by the intent or null if none specified by the
* intent.
*/
private Set<Account> getAllowableAccountSet(final Intent intent) {
Set<Account> setOfAllowableAccounts = null;
final ArrayList<Parcelable> validAccounts =
intent.getParcelableArrayListExtra(EXTRA_ALLOWABLE_ACCOUNTS_ARRAYLIST);
if (validAccounts != null) {
setOfAllowableAccounts = new HashSet<>(validAccounts.size());
for (Parcelable parcelable : validAccounts) {
setOfAllowableAccounts.add((Account) parcelable);
}
}
return setOfAllowableAccounts;
}
示例6: setPasswordInternal
import android.accounts.Account; //导入依赖的package包/类
private void setPasswordInternal(int userId, Account account, String password) {
synchronized (accountsByUserId) {
VAccount vAccount = getAccount(userId, account);
if (vAccount != null) {
vAccount.password = password;
vAccount.authTokens.clear();
saveAllAccounts();
synchronized (authTokenRecords) {
Iterator<AuthTokenRecord> iterator = authTokenRecords.iterator();
while (iterator.hasNext()) {
AuthTokenRecord record = iterator.next();
if (record.userId == userId && record.account.equals(account)) {
iterator.remove();
}
}
}
sendAccountsChangedBroadcast(userId);
}
}
}
示例7: handleSignInResult
import android.accounts.Account; //导入依赖的package包/类
protected void handleSignInResult(GoogleSignInResult result) {
Schedulers.newThread()
.scheduleDirect(() -> {
if (result.isSuccess()) {
if (result.getSignInAccount() != null && result.getSignInAccount().getAccount() != null) {
Account account = result.getSignInAccount().getAccount();
try {
String token = GoogleAuthUtil.getToken(activity, account, "oauth2:" + SCOPE_PICASA);
emitter.onSuccess(new GoogleSignIn.SignInAccount(token, result.getSignInAccount()));
} catch (IOException | GoogleAuthException e) {
emitter.onError(new SignInException("SignIn", e));
}
} else {
emitter.onError(new SignInException("SignIn", "getSignInAccount is null!", 0));
}
} else {
if (result.getStatus().getStatusCode() == CommonStatusCodes.SIGN_IN_REQUIRED) {
emitter.onError(new SignInRequiredException());
} else {
emitter.onError(new SignInException("SignIn", result.getStatus().getStatusMessage(), result.getStatus().getStatusCode()));
}
}
});
}
示例8: getCustomAuthToken
import android.accounts.Account; //导入依赖的package包/类
private String getCustomAuthToken(int userId, Account account, String authTokenType, String packageName) {
AuthTokenRecord record = new AuthTokenRecord(userId, account, authTokenType, packageName);
String authToken = null;
long now = System.currentTimeMillis();
synchronized (authTokenRecords) {
Iterator<AuthTokenRecord> iterator = authTokenRecords.iterator();
while (iterator.hasNext()) {
AuthTokenRecord one = iterator.next();
if (one.expiryEpochMillis > 0 && one.expiryEpochMillis < now) {
iterator.remove();
} else if (record.equals(one)) {
authToken = record.authToken;
}
}
}
return authToken;
}
示例9: confirmCredentials
import android.accounts.Account; //导入依赖的package包/类
public void confirmCredentials(int userId, IAccountManagerResponse response, final Account account, final Bundle options, final boolean expectActivityLaunch) {
if (response == null) throw new IllegalArgumentException("response is null");
if (account == null) throw new IllegalArgumentException("account is null");
AuthenticatorInfo info = getAuthenticatorInfo(account.type);
if (info == null) {
try {
response.onError(ERROR_CODE_BAD_ARGUMENTS, "account.type does not exist");
} catch (RemoteException e) {
e.printStackTrace();
}
return;
}
new Session(response, userId, info, expectActivityLaunch, true, account.name, true, true) {
@Override
public void run() throws RemoteException {
mAuthenticator.confirmCredentials(this, account, options);
}
}.bind();
}
示例10: after
import android.accounts.Account; //导入依赖的package包/类
@Override
protected void after(XParam param) throws Throwable {
if (mMethod == Methods.getToken || mMethod == Methods.getTokenWithNotification) {
if (param.args.length > 1) {
String accountName = null;
if (param.args[1] instanceof String)
accountName = (String) param.args[1];
else if (param.args[1] instanceof Account)
accountName = ((Account) param.args[1]).type;
if (param.getResult() != null && isRestrictedExtra(param, accountName))
param.setThrowable(new IOException("XPrivacy"));
}
} else
Util.log(this, Log.WARN, "Unknown method=" + param.method.getName());
}
示例11: renameAccountInternal
import android.accounts.Account; //导入依赖的package包/类
private Account renameAccountInternal(int userId, Account accountToRename, String newName) {
// TODO: Cancel Notification
synchronized (accountsByUserId) {
VAccount vAccount = getAccount(userId, accountToRename);
if (vAccount != null) {
vAccount.previousName = vAccount.name;
vAccount.name = newName;
saveAllAccounts();
Account newAccount = new Account(vAccount.name, vAccount.type);
synchronized (authTokenRecords) {
for (AuthTokenRecord record : authTokenRecords) {
if (record.userId == userId && record.account.equals(accountToRename)) {
record.account = newAccount;
}
}
}
sendAccountsChangedBroadcast(userId);
return newAccount;
}
}
return accountToRename;
}
示例12: confirmCredentials
import android.accounts.Account; //导入依赖的package包/类
public void confirmCredentials(int userId, IAccountManagerResponse response, final Account account, final Bundle options, final boolean expectActivityLaunch) {
if (response == null) throw new IllegalArgumentException("response is null");
if (account == null) throw new IllegalArgumentException("account is null");
AuthenticatorInfo info = getAuthenticatorInfo(account.type);
if(info == null) {
try {
response.onError(ERROR_CODE_BAD_ARGUMENTS, "account.type does not exist");
} catch(RemoteException e) {
e.printStackTrace();
}
return;
}
new Session(response, userId, info, expectActivityLaunch, true, account.name, true, true) {
@Override
public void run() throws RemoteException {
mAuthenticator.confirmCredentials(this, account, options);
}
}.bind();
}
示例13: peekAuthToken
import android.accounts.Account; //导入依赖的package包/类
@Override
public String peekAuthToken(int userId, Account account, String authTokenType) {
if (account == null) throw new IllegalArgumentException("account is null");
if (authTokenType == null) throw new IllegalArgumentException("authTokenType is null");
synchronized (accountsByUserId) {
VAccount vAccount = getAccount(userId, account);
if (vAccount != null) {
return vAccount.authTokens.get(authTokenType);
}
return null;
}
}
示例14: getAuthToken
import android.accounts.Account; //导入依赖的package包/类
public void getAuthToken(IAccountManagerResponse response, Account account, String authTokenType, boolean notifyOnAuthFailure, boolean expectActivityLaunch, Bundle loginOptions) {
try {
getRemote().getAuthToken(VUserHandle.myUserId(), response, account, authTokenType, notifyOnAuthFailure, expectActivityLaunch, loginOptions);
} catch (RemoteException e) {
e.printStackTrace();
}
}
示例15: updateCredentials
import android.accounts.Account; //导入依赖的package包/类
@Override
public void updateCredentials(int userId, final IAccountManagerResponse response, final Account account,
final String authTokenType, final boolean expectActivityLaunch,
final Bundle loginOptions) {
if (response == null) throw new IllegalArgumentException("response is null");
if (account == null) throw new IllegalArgumentException("account is null");
if (authTokenType == null) throw new IllegalArgumentException("authTokenType is null");
AuthenticatorInfo info = this.getAuthenticatorInfo(account.type);
if (info == null) {
try {
response.onError(ERROR_CODE_BAD_ARGUMENTS, "account.type does not exist");
} catch (RemoteException e) {
e.printStackTrace();
}
return;
}
new Session(response, userId, info, expectActivityLaunch, false, account.name) {
@Override
public void run() throws RemoteException {
mAuthenticator.updateCredentials(this, account, authTokenType, loginOptions);
}
@Override
protected String toDebugString(long now) {
if (loginOptions != null) loginOptions.keySet();
return super.toDebugString(now) + ", updateCredentials"
+ ", " + account
+ ", authTokenType " + authTokenType
+ ", loginOptions " + loginOptions;
}
}.bind();
}