Hi,
I have a block about the overall architecture/control of my app. I
have an authenticator service which runs correctly from Settings (I
can Add Account and set username/password).

Now I want to have a 'login' button in my app which uses the
AccountManager account and initiates the credentials check and returns
a success result to the main activity if all ok.

I have classes MainActivity(extends Activity),
AuthenticatorService(extends Service), Authenticator(extends
AbstractAccountAuthenticator), AuthenticatorActivity(extends
AccountAuthenticatorActivity), and a NetworkUtilities class which
performs  the http.

The relevant bit of the main activity contains:

   @Override
    public void onResume() {
        super.onResume();
        AccountManager accountManager =
AccountManager.get(getApplicationContext());
        Account[] accounts =
accountManager.getAccountsByType("com.sf.sf3");
        if (accounts.length > 0) {
                Account account = accounts[0];
                new loginTask().execute(account);
        }
    }

    private class loginTask extends AsyncTask<Account, Void, Void> {

        @Override
        protected Void doInBackground(Account... params) {
                AccountManager accountManager =
AccountManager.get(getApplicationContext());
                Account account = params[0];
                Bundle options  = new Bundle();
                AccountManagerFuture<Bundle> bundle =
accountManager.getAuthToken(account,PARAM_AUTHTOKEN_TYPE, options,
null, null,  null);
            return null;
        }

        @Override
        protected void onPostExecute(Void result) {
            Log.i("LOGINTASK:", "SUCCESS");
        }
    }

Not sure if Async class in the right place here but it stopped an ANR
error.

This launches the service(I can see this in the debugger) associated
with the account but I do not get the sign in form - probably because
the Authenticator associated with the  service doesn't get called.

Is this completely the wrong way to achieve the login on the app?
Sorry but I am out of ideas and could do with some glue! If I could
grasp the control flow for checking user credentials across my app I
would be able to move on. Any help very appreciated.

                                                 Thanks
 
Alex (new to android)









-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to