本文整理汇总了Java中android.accounts.OperationCanceledException类的典型用法代码示例。如果您正苦于以下问题:Java OperationCanceledException类的具体用法?Java OperationCanceledException怎么用?Java OperationCanceledException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
OperationCanceledException类属于android.accounts包,在下文中一共展示了OperationCanceledException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: syncLogon4LetvPhone
import android.accounts.OperationCanceledException; //导入依赖的package包/类
private void syncLogon4LetvPhone() {
new Thread() {
public void run() {
try {
String blockingGetAuthToken = LogonManager.this.accountManager.blockingGetAuthToken(LogonManager.this.accounts[0], LogonManager.this.AUTH_TOKEN_TYPE_LETV, true);
LemallPlatform.getInstance().setSsoToken(blockingGetAuthToken);
LogonManager.this.syncToken4Logon(blockingGetAuthToken, (IWebviewListener) LogonManager.this.context);
} catch (OperationCanceledException e) {
e.printStackTrace();
} catch (AuthenticatorException e2) {
e2.printStackTrace();
} catch (IOException e3) {
e3.printStackTrace();
}
}
}.start();
}
示例2: doInBackground
import android.accounts.OperationCanceledException; //导入依赖的package包/类
protected Bundle doInBackground(Void... params) {
try {
return this.this$0.tryAddXiaomiAccount(this.val$activity);
} catch (SecurityException e) {
e.printStackTrace();
this.retryWebViewWay = true;
return null;
} catch (OperationCanceledException e2) {
e2.printStackTrace();
return null;
} catch (AuthenticatorException e3) {
e3.printStackTrace();
this.retryWebViewWay = true;
return null;
} catch (IOException e4) {
e4.printStackTrace();
return null;
}
}
示例3: addNewAccount
import android.accounts.OperationCanceledException; //导入依赖的package包/类
private void addNewAccount() {
mAccountManager.addAccount(EnlightnsAccountAuthenticator.ACCOUNT_TYPE,
EnlightnsAccountAuthenticator.AUTH_TOKEN_TYPE, null, null, this, new AccountManagerCallback<Bundle>() {
@Override
public void run(AccountManagerFuture<Bundle> future) {
try {
Bundle bnd = future.getResult();
showMessage(getString(R.string.successful_login_toast));
new GetUserRecordsTask().execute();
Log.d(TAG, "AddNewAccount Bundle is " + bnd);
} catch (OperationCanceledException oce) {
Log.d(TAG, "Operation cancelled, no account available, exiting...", oce);
finish();
} catch (Exception e) {
Log.w(TAG, "Exception", e);
showMessage(getString(R.string.login_error));
}
}
}, null);
}
示例4: onPerformSync
import android.accounts.OperationCanceledException; //导入依赖的package包/类
@Override
public void onPerformSync(Account account, Bundle extras, String authority, ContentProviderClient provider, SyncResult syncResult) {
try {
String username = mAccountManager.blockingGetAuthToken(account, AccountGeneral.AUTHTOKEN_TYPE_FULL_ACCESS, true);
SyncServerInterface serverInterface = new SyncServerInterface(getContext());
User user = serverInterface.getUserInfo(username);
UserContentHelper.clearUsers(getContext());
if (user != null) {
UserContentHelper.addUser(getContext(), user);
}
} catch (OperationCanceledException | IOException | AuthenticatorException e) {
e.printStackTrace();
syncResult.stats.numParseExceptions++;
}
}
示例5: a
import android.accounts.OperationCanceledException; //导入依赖的package包/类
public Account[] a(String paramString, String[] paramArrayOfString)
{
try
{
Account[] arrayOfAccount = (Account[])AccountManager.get(this.a).getAccountsByTypeAndFeatures(paramString, paramArrayOfString, null, null).getResult(b, TimeUnit.MILLISECONDS);
return arrayOfAccount;
}
catch (AuthenticatorException localAuthenticatorException)
{
throw new fpv(localAuthenticatorException);
}
catch (OperationCanceledException localOperationCanceledException)
{
throw new IOException(localOperationCanceledException);
}
}
示例6: run
import android.accounts.OperationCanceledException; //导入依赖的package包/类
public void run(AccountManagerFuture<Bundle> result) {
Bundle bundle;
try {
bundle = result.getResult();
Intent intent = (Intent)bundle.get(AccountManager.KEY_INTENT);
if(intent != null) {
// User input required
context.startActivity(intent);
} else {
AccountManager.get(context).invalidateAuthToken(bundle.getString(AccountManager.KEY_ACCOUNT_TYPE), bundle.getString(AccountManager.KEY_AUTHTOKEN));
AccountManager.get(context).invalidateAuthToken("ah", bundle.getString(AccountManager.KEY_AUTHTOKEN));
onGetAuthToken(bundle);
}
} catch (OperationCanceledException | AuthenticatorException | IOException e) {
//notifyUser(context.getString(R.string.flowzr_sync_error_no_network), 100);
//showErrorPopup(FlowzrSyncActivity.this, R.string.flowzr_sync_error_no_network);
//context.setReady();
e.printStackTrace();
}
}
示例7: getToken
import android.accounts.OperationCanceledException; //导入依赖的package包/类
@Override
public AndroidToken getToken(Account account, AndroidTokenType type) throws AuthenticationCanceledException {
try {
AndroidToken token;
Activity activity = activityManager.getActivity();
if (account == null) {
token = createAccountAndGetToken(activity, type);
} else {
token = getToken(activity, account, type);
}
if (token == null) {
throw new AuthenticationCanceledException("user canceled the login!");
}
return token;
} catch (AuthenticatorException | OperationCanceledException | IOException e) {
throw new AuthenticationCanceledException(e);
}
}
示例8: createAccountAndGetToken
import android.accounts.OperationCanceledException; //导入依赖的package包/类
private AndroidToken createAccountAndGetToken(@Nullable Activity activity, @NonNull AndroidTokenType type)
throws AuthenticatorException, OperationCanceledException, IOException {
AccountManagerFuture<Bundle> future = accountManager
.addAccount(type.accountType, type.tokenType, null, null, activity, null, null);
Bundle result = future.getResult();
String accountName = result.getString(AccountManager.KEY_ACCOUNT_NAME);
if (accountName != null) {
Account account = new Account(result.getString(AccountManager.KEY_ACCOUNT_NAME),
result.getString(AccountManager.KEY_ACCOUNT_TYPE));
String token = accountManager.peekAuthToken(account, type.tokenType);
String refreshToken = accountManager.peekAuthToken(account, getRefreshTokenType(type));
if (token != null) return new AndroidToken(token, refreshToken);
}
return null;
}
示例9: getToken
import android.accounts.OperationCanceledException; //导入依赖的package包/类
@Override
protected Token getToken() throws AuthFailureError {
String tokenStr;
try {
// NOTE: We pass true for notifyAuthFailure for clarity, but our authenticator always
// assumes it is true, because AccountManager#KEY_NOTIFY_ON_FAILURE is a hidden API.
tokenStr = mAccountManager.blockingGetAuthToken(
mAccount, AccountAuthenticator.TOKEN_TYPE_OAUTH, true /* notifyAuthFailure */);
} catch (AuthenticatorException | OperationCanceledException | IOException e) {
throw new AuthFailureError("Unable to obtain auth token", e);
}
mToken = WireUtil.decodeFromString(tokenStr, Token.class);
if (mToken == null) {
throw new AuthFailureError("Error decoding token string");
}
return mToken;
}
示例10: getClientFor
import android.accounts.OperationCanceledException; //导入依赖的package包/类
@Override
public OwnCloudClient getClientFor(OwnCloudAccount account, Context context)
throws AccountNotFoundException, OperationCanceledException, AuthenticatorException,
IOException {
Log_OC.d(TAG, "getClientFor(OwnCloudAccount ... : ");
OwnCloudClient client = OwnCloudClientFactory.createOwnCloudClient(
account.getBaseUri(),
context.getApplicationContext(),
true);
Log_OC.v(TAG, " new client {" +
(account.getName() != null ?
account.getName() :
AccountUtils.buildAccountName(account.getBaseUri(), "")
) + ", " + client.hashCode() + "}");
if (account.getCredentials() == null) {
account.loadCredentials(context);
}
client.setCredentials(account.getCredentials());
return client;
}
示例11: saveAllClients
import android.accounts.OperationCanceledException; //导入依赖的package包/类
@Override
public void saveAllClients(Context context, String accountType)
throws AccountNotFoundException, AuthenticatorException, IOException,
OperationCanceledException {
if (Log.isLoggable(TAG, Log.DEBUG)) {
Log_OC.d(TAG, "Saving sessions... ");
}
Iterator<String> accountNames = mClientsWithKnownUsername.keySet().iterator();
String accountName = null;
Account account = null;
while (accountNames.hasNext()) {
accountName = accountNames.next();
account = new Account(accountName, accountType);
AccountUtils.saveClient(
mClientsWithKnownUsername.get(accountName),
account,
context);
}
if (Log.isLoggable(TAG, Log.DEBUG)) {
Log_OC.d(TAG, "All sessions saved");
}
}
示例12: getQuestions
import android.accounts.OperationCanceledException; //导入依赖的package包/类
public JSONObject getQuestions(QuestionsGetRequest request) throws IOException, JSONException, InvalidAccessTokenException, AuthenticatorException, OperationCanceledException, ServerErrorException {
UrlParams params = new UrlParams();
params.add("first_question_id", request.getFirstQuestionId());
params.add("limit", request.getLimit());
params.add("offset", request.getOffset());
params.add("tab", request.getContentSection().toString().toLowerCase());
for (int category : request.getCategories()) {
params.add("categories[]", category);
}
HttpResponse response = makeProtectedGetCall(resolveApiUrl(request.getPath()), params);
if (response == null || response.getBody() == null) {
return null;
}
return new JSONObject(response.getBody());
}
示例13: uploadImage
import android.accounts.OperationCanceledException; //导入依赖的package包/类
public JSONObject uploadImage(ImageUploadRequest request) throws JSONException, IOException, InvalidAccessTokenException, AuthenticatorException, OperationCanceledException, ServerErrorException {
UrlParams params = new UrlParams();
ImageData image = request.getImage();
ImageParamFacade imageParamFacade = new ImageParamFacade(image);
try {
imageParamFacade.write(params, "image", "preview");
HttpResponse response = makeProtectedMultipartPostCall(resolveApiUrl(request.getPath()), params);
if (response == null || response.getBody() == null) {
return null;
}
return new JSONObject(response.getBody());
} finally {
imageParamFacade.close();
}
}
示例14: run
import android.accounts.OperationCanceledException; //导入依赖的package包/类
@Override
public void run(AccountManagerFuture<Bundle> bundleAccountManagerFuture) {
try {
Bundle result = bundleAccountManagerFuture.getResult();
Intent intent = (Intent) result.get(AccountManager.KEY_INTENT);
if (intent == null) {
String authToken = result.getString(AccountManager.KEY_AUTHTOKEN);
GutenbergApplication app = GutenbergApplication.from(BaseActivity.this);
app.setAuthToken(authToken);
app.requestSync(false);
} else {
startActivityForResult(intent, REQUEST_AUTHENTICATE);
}
} catch (OperationCanceledException | IOException | AuthenticatorException e) {
Log.e(TAG, "Error authenticating.", e);
}
}
示例15: addAccount
import android.accounts.OperationCanceledException; //导入依赖的package包/类
private void addAccount(String accountName) {
AccountManager accountManager = AccountManager.get(this);
Bundle bundle = new Bundle();
if (!TextUtils.isEmpty(accountName)) {
bundle.putString(AccountManager.KEY_ACCOUNT_NAME, accountName);
}
accountManager.addAccount(GOOGLE_ACCOUNT_TYPE, null, null, bundle, this,
accountManagerFuture -> {
try {
Bundle result = accountManagerFuture.getResult();
String accountNameAdded = result.getString(AccountManager.KEY_ACCOUNT_NAME);
Log.d(TAG, "addAccount - accountNameAdded: " + accountNameAdded);
if (mNextActivityIntent != null) {
startActivity(mNextActivityIntent);
}
finish();
} catch (OperationCanceledException | AuthenticatorException
| IOException e) {
Log.e(TAG, "addAccount - failed", e);
Toast.makeText(AddAccountActivity.this,
R.string.fail_to_add_account, Toast.LENGTH_LONG).show();
}
}, null);
}