1

I'm trying to follow this this example: 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.

My code is a bit bad-written, but it's published in Google Code. The workflow I'm trying to establish is here: http://code.google.com/p/phone-to-desktop/source/browse/src/net/xisberto/phonetodesktop/PhoneToDesktopActivity.java?spec=svnd70158809aeb1ba00e26a33dc7110ade33b76427&name=google-tasks&r=d70158809aeb1ba00e26a33dc7110ade33b76427

In my last try, when the app goes to the following method:

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);
}

And all I get is no visual alterations and these messages in 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)

Any help/tutorial/code example that could help?

Thanks in advance.

Xisberto
  • 125
  • 3
  • 12

2 Answers2

3

you use mail jar file, activation.jar and additional jar file use and following code are use for connectivity email application to server email..

            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 ");

I hope this can help u !

Akash Singh
  • 5,171
  • 2
  • 26
  • 55
-3

Ok, I got to manage the authentication. I was failing to understand the process and the values to set. Now my code is better written and works nicer.

Xisberto
  • 125
  • 3
  • 12
  • Can you explain what you did and share the knowledge? – Phillip May 25 '12 at 19:05
  • 1
    @xisberto - this is a comment, not an answer. if you are going to put it as an answer, you have to spell out the solution, with code. ta vacilando, Xb3rt0... – tony gil Jul 23 '12 at 17:40
  • Ok, understood. As I said, my code is open-source, and it is published now on GitHub: github.com/xisberto/phonetodesktop – Xisberto Nov 27 '12 at 13:17