本文整理汇总了Java中com.google.android.gms.auth.UserRecoverableNotifiedException类的典型用法代码示例。如果您正苦于以下问题:Java UserRecoverableNotifiedException类的具体用法?Java UserRecoverableNotifiedException怎么用?Java UserRecoverableNotifiedException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
UserRecoverableNotifiedException类属于com.google.android.gms.auth包,在下文中一共展示了UserRecoverableNotifiedException类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getGoogleAuthToken
import com.google.android.gms.auth.UserRecoverableNotifiedException; //导入依赖的package包/类
private String getGoogleAuthToken() throws IOException {
String googleUserName = PrefsUtil.retrieveGoogleTasksUser(mContext);
String token = "";
try {
Log.d(TAG, "getGoogleAuthToken... "+googleUserName);
token = GoogleAuthUtil.getTokenWithNotification(mContext,
googleUserName, GoogleTaskApiService.SCOPE, null);
} catch (UserRecoverableNotifiedException userNotifiedException) {
// Notification has already been pushed.
// Continue without token or stop background task.
} catch (GoogleAuthException authEx) {
// This is likely unrecoverable.
Log.e(TAG,
"Unrecoverable authentication exception: "
+ authEx.getMessage(), authEx);
}
return token;
}
示例2: fetchToken
import com.google.android.gms.auth.UserRecoverableNotifiedException; //导入依赖的package包/类
/**
* Get a authentication token if one is not available. If the error was recoverable then a
* notification will automatically be pushed. The callback provided will be fired once the
* notification is addressed by the user successfully. If the error is not recoverable then
* it displays the error message on parent activity.
*/
@Override
protected String fetchToken() throws IOException {
try {
return GoogleAuthUtil.getTokenWithNotification(
mActivity, mEmail, mScope, null, makeCallback(mEmail));
} catch (UserRecoverableNotifiedException userRecoverableException) {
// Unable to authenticate, but the user can fix this.
// Because we've used getTokenWithNotification(), a Notification is
// created automatically so the user can recover from the error
onError("Could not fetch token.", null);
} catch (GoogleAuthException fatalException) {
onError("Unrecoverable error " + fatalException.getMessage(), fatalException);
}
return null;
}
示例3: fetchToken
import com.google.android.gms.auth.UserRecoverableNotifiedException; //导入依赖的package包/类
@Override
protected String fetchToken() throws IOException {
try {
return GoogleAuthUtil.getTokenWithNotification(
mActivity, mEmail, mScope, null, CONTACTS_AUTHORITY, null);
} catch (UserRecoverableNotifiedException userRecoverableException) {
// Unable to authenticate, but the user can fix this.
// Because we've used getTokenWithNotification(), a Notification is
// created automatically so the user can recover from the error
onError("Could not fetch token.", null);
} catch (GoogleAuthException fatalException) {
onError("Unrecoverable error " + fatalException.getMessage(), fatalException);
}
return null;
}
示例4: doAuth
import com.google.android.gms.auth.UserRecoverableNotifiedException; //导入依赖的package包/类
public void doAuth () throws OperationCanceledException, AuthenticatorException, IOException, UserRecoverableNotifiedException, GoogleAuthException
{
Bundle bund = new Bundle();
token = GoogleAuthUtil.getTokenWithNotification(InformaService.getInstance().getApplicationContext(), account.name, Models.ITransportStub.GoogleDrive.SCOPE,bund);
if (bund.containsKey(AccountManager.KEY_AUTHTOKEN))
token = bund.getString(AccountManager.KEY_AUTHTOKEN);
/**
if (token != null)
am.invalidateAuthToken(Models.ITransportStub.GoogleDrive.SCOPE, token);
AccountManagerFuture<Bundle> response = am.getAuthToken(account, Models.ITransportStub.GoogleDrive.SCOPE, true, new AccountManagerCallback<Bundle> () {
@Override
public void run(AccountManagerFuture<Bundle> result) {
try {
token = result.getResult().getString(AccountManager.KEY_AUTHTOKEN);
} catch (OperationCanceledException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (AuthenticatorException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}, null);
Bundle b;
b = response.getResult();
token = b.getString(AccountManager.KEY_AUTHTOKEN);
*/
}