Googleアカウントから認証トークンを取得する際にはNick exampleに従います。 AccountManagerFuture getResultを呼び出すときに私が立ち往生します。私は自分のデバイス(HTCの欲望)とEclipseから始まったローカルのGoogleアプリケーションエンジンで作業しています。携帯電話でインターネットに接続すると、認証トークンを取得できます。しかし、私はそれをローカルでオフラインでやりたいと思います。私はそれを動作させるためにインターネットに接続する必要があるかどうか知っていますか? もしそうでなければ、getResultメソッドが何をするのかははっきりしない。どこかのGoogleサーバーからトークンを取得しますか?おかげさまで Android AccountManagerFuture getResultは許可トークンを取得しようとするとIOEXcelptionを返します
@Override
protected void onResume() {
super.onResume();
Intent intent = getIntent();
AccountManager accountManager = AccountManager.get(getApplicationContext());
Account account = (Account)intent.getExtras().get("account");
accountManager.getAuthToken(account, "ah", false, new GetAuthTokenCallback(), null);
}
private class GetAuthTokenCallback implements AccountManagerCallback<Bundle> {
public void run(AccountManagerFuture<Bundle> result) {
Bundle bundle;
try {
System.out.println("result.isCancelled"+result.isCancelled());
// this prints false
System.out.println("result.isDone"+result.isDone());
//this prints true
bundle = result.getResult();
// when getResult is called I get an IOException without further details
Intent intent = (Intent)bundle.get(AccountManager.KEY_INTENT);
if(intent != null) {
startActivity(intent);
} else {
onGetAuthToken(bundle);
}
} catch (OperationCanceledException e) {
e.printStackTrace();
} catch (AuthenticatorException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
};
3月19日13:58:03.933:System.errの(1801)/ W:java.io.IOExceptionの 3月19日13:58:03.933:(1801)をSystem.err/W:でandroid.accounts.AccountManager.convertErrorToException(AccountManager.java:1419) 03-19 13:58:03.933:W/System.err(1801):android.accounts.AccountManager.access $ 400(AccountManager.java:134) 03-19 13:58:03.933:W/System.err(1801):android.accounts.AccountManager $ AmsTask $ Response.onError(AccountManager.java:1280) 03-19 13:58:03.933:W/System .err(1801):android.accounts.IAccountManagerResponse $ Stub.onTransact(IAccountManagerResponse.java:69) 03-19 13:58:03.933:W/System.err(1801):android.os.Binder.execTra nsact(Binder.java:288) 03-19 13:58:03.933:W/System.err(1801):at dalvik.system.NativeStart.run(ネイティブメソッド)