我的代码写得有点糟糕,但它是在 Google Code 中发布的。我要建立的工作流程在这里:http ://code.google.com/p/phone-to-desktop/source/browse/src/net/xisberto/phonetodesktop/PhoneToDesktopActivity.java?spec=svnd70158809aeb1ba00e26a33dc7110ade33b76427&name=google -tasks&r=d70158809aeb1ba00e26a33dc7110ade33b76427
在我最后一次尝试中,当应用程序转到以下方法时:
private void chooseAccount() {
Log.i(getPackageName(), "Starting authenticate");
AccountManager manager = AccountManager.get(getApplicationContext());
manager.getAuthTokenByFeatures(
"google.com",
"Manage your tasks",
null, PhoneToDesktopActivity.this, null, null,
new AccountManagerCallback<Bundle>() {
@Override
public void run(AccountManagerFuture<Bundle> future) {
try {
Bundle bundle = future.getResult();
//So we save the account and token
setAccountName(bundle.getString(PREF_ACCOUNT_NAME));
setAuthToken(bundle.getString(PREF_AUTH_TOKEN));
Toast.makeText(getApplicationContext(),
"Account authenticated: " +
bundle.getString(PREF_ACCOUNT_NAME) + "\n" +
bundle.getString(PREF_AUTH_TOKEN),
Toast.LENGTH_SHORT).
show();
//Then we create the list we will use
createList();
} catch (OperationCanceledException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (AuthenticatorException e) {
Log.e(getApplicationInfo().packageName, e.getMessage(), e);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
},
null);
}
我得到的只是没有视觉上的改变和 DDMS 中的这些消息:
04-18 00:59:53.187: E/net.xisberto.phonetodesktop(10488): bind failure
04-18 00:59:53.187: E/net.xisberto.phonetodesktop(10488): android.accounts.AuthenticatorException: bind failure
04-18 00:59:53.187: E/net.xisberto.phonetodesktop(10488): at android.accounts.AccountManager.convertErrorToException(AccountManager.java:1450)
04-18 00:59:53.187: E/net.xisberto.phonetodesktop(10488): at android.accounts.AccountManager.access$400(AccountManager.java:138)
04-18 00:59:53.187: E/net.xisberto.phonetodesktop(10488): at android.accounts.AccountManager$AmsTask$Response.onError(AccountManager.java:1296)
04-18 00:59:53.187: E/net.xisberto.phonetodesktop(10488): at android.accounts.IAccountManagerResponse$Stub.onTransact(IAccountManagerResponse.java:69)
04-18 00:59:53.187: E/net.xisberto.phonetodesktop(10488): at android.os.Binder.execTransact(Binder.java:339)
04-18 00:59:53.187: E/net.xisberto.phonetodesktop(10488): at dalvik.system.NativeStart.run(Native Method)
任何可以帮助的帮助/教程/代码示例?
提前致谢。