1

我正在尝试遵循此示例:http ://code.google.com/p/google-api-java-client/source/browse/tasks-android-sample/src/main/java/com/google/ api/services/samples/tasks/android/TasksSample.java?repo=samples

我的代码写得有点糟糕,但它是在 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)

任何可以帮助的帮助/教程/代码示例?

提前致谢。

4

2 回答 2

3

您使用邮件 jar 文件、activation.jar 和其他 jar 文件使用,以下代码用于将电子邮件应用程序连接到服务器电子邮件。

            Properties props = System.getProperties();
            props.setProperty("mail.store.protocol", "imaps");
            props.put("mail.smtp.starttls.enable","true");
            Authenticator auth = new Authenticator() {
                protected PasswordAuthentication getPasswordAuthentication(){
                    return new PasswordAuthentication("USEREMAILID","PASSWORD ");
                    }
            };
            sessioned= Session.getDefaultInstance(props, auth);
            store = sessioned.getStore("imaps");
            store.connect("smtp.gmail.com","USEREMAILID","PASSWORD ");

我希望这可以帮助你!

于 2012-04-19T05:03:23.573 回答
-3

好的,我必须管理身份验证。我无法理解要设置的过程和值。现在我的代码写得更好,效果更好。

于 2012-04-27T19:33:56.330 回答