At least... this is as far as I understand it.... Please correct me if I'm wrong here.
Also, if a google rep can speak to this point: If I have a few apps that all utilize a certain account type... What's the best recommended way of letting them all function independently of each other, or all installed at the same time? It looks like if I include a service and authenticator in each application... won't there be way too many services? Will the authenticators for the same type conflict? Should the account type be relegated to a dependancy package? Are there means for requiring other packages when downloading an app from the market seamlessly? On Fri, Nov 20, 2009 at 7:53 AM, Dan Dumont <[email protected]> wrote: > Yes. But I make the AddAccountExplicitly call in my Authenticator. You > use the AccountManager to create accounts. > If you call AddAccountExplicitly from a non-authenticator class, I guess it > will work... But I think the security behind it will mean that only the > class that created the account will be able to ever modify it or extract the > password. > > This is why they have a framework for you to get an authtoken returned via > the authenticator... the logic for authenticating should be buried within > there, because it will be the only class allowed to peak at the password and > send it wherever you are authenticating. > > > On Fri, Nov 20, 2009 at 2:16 AM, sukumar bhashyam < > [email protected]> wrote: > >> AddAccountExplicitly() would need Authenticator of same type. >> >> I created an Authenticator and called AddAccountExplicitly() for the same >> type which created an account ( Could verify it from >> AccountManager.getAccounts()) >> >> One strange thing I observer is none of the implementation class >> functions of AbstractAccountAuthenticator is being called. I followed the >> exact steps in documentation. Not even onCreate or onBind function is >> called. Anyone seen this problem?. Is your AbstractAccountAuthenticator >> implemetation class being invoked?. >> Thanks. >> >> >> On Thu, Nov 19, 2009 at 8:26 PM, Jerry Brady <[email protected]>wrote: >> >>> Dan, >>> >>> Thanks for all of this. I just returned to the office and will be >>> taking a look to see how much further I can get and I will certainly >>> be interested in helping with your accounts project. >>> >>> I got as far as getting my account to show up in the list of accounts >>> along with Google, Facebook and Exchange, but my service never gets >>> called. My addAccount() method doesn't return an intent, but rather >>> KEY_ACCOUNT_NAME and KEY_ACCOUNT_TYPE in it's bundle to let the >>> account request succeed. >>> >>> My goal is to create an account that will only be used by my >>> application and does not need to have any features to enable external >>> authentication or account configuration. >>> >>> I've also tried AddAccountExplicitly() but I can't seem to get around >>> its UID restrictions. The calling activity and the authenticator >>> service all belong to the same application so I'm not sure why the >>> system still throws an error about the UID not being correct. >>> >>> Cheers, >>> Jerry >>> >>> On Nov 13, 11:54 pm, Dan Dumont <[email protected]> wrote: >>> > For anyone still interested. I've made a bit of progress. The >>> google >>> > project below now creates and lists accounts of the type for the >>> project! >>> > >>> > >>> > >>> > On Fri, Nov 13, 2009 at 9:39 PM, Dan Dumont <[email protected]> wrote: >>> > > To facilitate the discussion around this topic, I've started up a >>> project >>> > > over here: >>> > >http://code.google.com/p/androidaccounts/ >>> > >>> > > <http://code.google.com/p/androidaccounts/>If anyone is interested >>> in >>> > > pitching in and writing some examples, let me know so I can add you. >>> > > The current state of the project is as far as I've gotten to >>> understanding >>> > > what is available so far... and I'm stumped as to why new accounts >>> don't >>> > > seem to persist after their creation ( as far as the AccountsTester >>> app is >>> > > concerned ). >>> > >>> > > On Fri, Nov 13, 2009 at 7:40 PM, Dan Dumont <[email protected]> >>> wrote: >>> > >>> > >> I've gotten a bit further than you. >>> > >>> > >> The account manager seems to want to store AccountName+Type pairs, >>> and >>> > >> have an AccountAuthenticator handle the storage and dirty bits of >>> the actual >>> > >> authentication and credential storage. >>> > >>> > >> You will need to create an AccountAuthenticator from the >>> > >> AbstractAccountAuthenticator class. >>> > >> You will also need to define a Service in your app. See >>> > >> >>> http://developer.android.com/reference/android/accounts/AbstractAccou... >>> > >> This service must be set up in the Manifest like so: (ripped from >>> link >>> > >> above) >>> > >>> > >> <intent-filter> >>> > >> <action android:name="android.accounts.AccountAuthenticator" /> >>> > >> </intent-filter> >>> > >> <meta-data android:name="android.accounts.AccountAuthenticator" >>> > >> android:resource="@xml/authenticator" /> >>> > >>> > >> You can take a look at the link for what the resource must be... >>> > >>> > >> After you end up hooking all that crap up, you can do this in your >>> > >> service: >>> > >> public IBinder onBind(Intent intent) { >>> > >> IBinder ret = null; >>> > >> if >>> > >> >>> (intent.getAction().equals(android.accounts.AccountManager.ACTION_AUTHENTIC >>> ATOR_INTENT)) >>> > >> ret = getAuthenticator().getIBinder(); >>> > >> return ret; >>> > >> } >>> > >>> > >> private AccountAuthenticator getSametimeAuthenticator() { >>> > >> if (_aa == null) >>> > >> _aa = new AccountAuthenticator(this); >>> > >> return _aa; >>> > >> } >>> > >>> > >> So when you finally have all this set up. You should see your >>> account >>> > >> type listed in the AccountTester application next to the "Corporate" >>> type. >>> > >> To get anything meaningful to happen when you click Add, you need to >>> do >>> > >> this in your AccountAuthenticator: >>> > >>> > >> public Bundle addAccount(AccountAuthenticatorResponse response, >>> String >>> > >> accountType, String authTokenType, String[] requiredFeatures, Bundle >>> > >> options) throws NetworkErrorException { >>> > >> Bundle ret = new Bundle(); >>> > >> Intent intent = new Intent(_context, >>> > >> AccountAuthenticatorActivity.class); >>> > >> intent.putExtra(AccountManager.KEY_ACCOUNT_AUTHENTICATOR_RESPONSE, >>> > >> response); >>> > >> ret.putParcelable(AccountManager.KEY_INTENT, intent); >>> > >> return ret; >>> > >> } >>> > >>> > >> This basically says that... I'm going to prompt the user to enter >>> > >> credentials using the MyAccountAuthenticatorActivity class. >>> > >> The MyAccountAuthenticatorActivity activity should probably extend >>> the >>> > >> class AccountAuthenticatorActivity. Here's mine: >>> > >>> > >> public class MyAccountAuthenticatorActivity extends >>> > >> AccountAuthenticatorActivity { >>> > >> protected void onCreate(Bundle icicle) { >>> > >> super.onCreate(icicle); >>> > >> setContentView(R.layout.new_account); >>> > >> final Button done = (Button)findViewById(R.id.new_account_done); >>> > >> final EditText server = >>> (EditText)findViewById(R.id.new_account_server); >>> > >> final EditText username = >>> > >> (EditText)findViewById(R.id.new_account_username); >>> > >> final EditText password = >>> > >> (EditText)findViewById(R.id.new_account_password); >>> > >> done.setOnClickListener(new OnClickListener() { >>> > >> public void onClick(View v) { >>> > >> Bundle result = new Bundle(); >>> > >> result.putString(AccountManager.KEY_ACCOUNT_NAME, >>> > >> username.getText().toString()); >>> > >> result.putString(AccountManager.KEY_ACCOUNT_TYPE, >>> > >> getString(R.string.ACCOUNT_TYPE)); >>> > >> setAccountAuthenticatorResult(result); >>> > >> finish(); >>> > >> } >>> > >> }); >>> > >> } >>> > >> } >>> > >>> > >> The bundle you would normally pass back if you had no Activity to >>> enter >>> > >> credentials is passed back with >>> setAccountAuthenticatorResult(result); >>> > >> and finish(); >>> > >>> > >> That's about as far as i've gotten. When i click Add in the >>> > >> AccountsTester app, the activity to enter creds is launched, and >>> whent he >>> > >> done button is pressed I get this message in the LogCat: >>> > >> 11-13 19:21:58.488: DEBUG/AccountsTester(291): account added: >>> > >> Bundle[{accountType=com.my.package.app.auth.account_type, >>> > >> authAccount=testaccout}] >>> > >>> > >> But the AccountsTester app refuses to display my accounts that it >>> said it >>> > >> created. >>> > >> without being able to look at the source for at least the >>> AccountsTester >>> > >> app, I'm pretty stuck right now... >>> > >> Does anyone out there have ANY useful information on how to use this >>> > >> stuff? Or is it all locked up in a buttbuddy secret vault between >>> google >>> > >> and motorola? >>> > >>> > >> On Thu, Nov 12, 2009 at 8:27 PM, Jerry Brady <[email protected] >>> >wrote: >>> > >>> > >>> I'm trying to hook up a new account for an application to use that >>> > >>> will ultimately sync PIM data. The application is already working >>> for >>> > >>> API levels 3 & 4, but at API 5, I'm having some trouble with the >>> > >>> introduction of accounts and the AccountManager. >>> > >>> > >>> I've searched the groups and the docs and gotten part way there, >>> but >>> > >>> for some reason there isn't any I can get an actual account >>> created. >>> > >>> I've tried both on the Moto Droid and in the emulator. >>> > >>> > >>> I have a service that implements everything as required by the >>> > >>> documentation for AbstractAccountAuthenticator. I've confirmed that >>> my >>> > >>> account is not present my iterating the results from >>> > >>> AccountManager.getAccounts(). >>> > >>> > >>> My service's authenticator shows up in when I iterate the result >>> from >>> > >>> AccountManager.getAuthenticatorTypes(). The name and package are >>> both >>> > >>> listed. >>> > >>> > >>> But when I have an activity call to add an account with AddAccount, >>> > >>> the call returns, but the future bundle never finishes. There is >>> > >>> nothing in logs indicates anything is happening and it's almost as >>> if >>> > >>> there is an Intent fired by the call to addAccount() that I'm not >>> > >>> setup to catch. >>> > >>> > >>> Since the eclair source isn't available yet, I can't look into it >>> on >>> > >>> my own and I'm asking for some help from people who know this part >>> of >>> > >>> 2.0 or have access to the source to help me find what I am missing. >>> > >>> > >>> In my activity, after using an initialized AccountManager to check >>> my >>> > >>> account, I call to set one up: >>> > >>> > >>> private final static String MY_ACCOUNT_TYPE = "com.mydomain"; >>> > >>> AccountManager am = AccountManager.get(context); >>> > >>> AccountManagerFuture<Bundle> future; >>> > >>> Bundle result; >>> > >>> > >>> future = am.addAccount(MS_ACCOUNT_TYPE, null, null, null, null, >>> null, >>> > >>> null); >>> > >>> > >>> Log.d(TAG, "returned from am.AddAccount"); >>> > >>> try { >>> > >>> result = future.getResult(); >>> > >>> } catch .... >>> > >>> > >>> When run, getResult() never finishes, ultimately blocking my >>> activity >>> > >>> until it's stopped. I don't know where the system goes after my >>> call >>> > >>> to getResult(). >>> > >>> > >>> The service I have created is configured just the like example from >>> > >>> the docs: >>> > >>> <service android:enabled="true" >>> > >>> android:exported="true" android:name="AccountService" >>> > >>> android:label="Sync Account"> >>> > >>> <intent-filter> >>> > >>> <action >>> > >>> android:name="android.accounts.AccountAuthenticator" /> >>> > >>> </intent-filter> >>> > >>> <meta-data >>> > >>> android:name="android.accounts.AccountAuthenticator" >>> > >>> android:resource="@xml/authenticator" /> >>> > >>> </service> >>> > >>> > >>> I'm wondering if there is a different intent I need to catch for >>> > >>> account creation. All of the service's lifecycle methods have >>> > >>> overrides and logging. It doesn't look as if my authenticator >>> service >>> > >>> is ever instantiated. >>> > >>> > >>> The only other question I had was in AbstractAccountAuthenticator >>> > >>> because the docs read that you must extend this class and return >>> the >>> > >>> correct value for getIBinder(). Since you can't extend from more >>> than >>> > >>> one class, I assumed this meant I needed to have my >>> > >>> AccountAuthenticator class treat the abstract class as an interface >>> > >>> and the class extends Binder to support the getIBinder() method. >>> > >>> > >>> I'd appreciate any insight or help anyone can offer. >>> > >>> > >>> Cheers, >>> > >>> Jerry >>> > >>> > >>> -- >>> > >>> 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]<android-developers%[email protected]><android-developers%2Bunsubs >>> [email protected]> >>> > >>> For more options, visit this group at >>> > >>>http://groups.google.com/group/android-developers?hl=en >>> >>> -- >>> 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]<android-developers%[email protected]> >>> For more options, visit this group at >>> http://groups.google.com/group/android-developers?hl=en >>> >> >> -- >> 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]<android-developers%[email protected]> >> For more options, visit this group at >> http://groups.google.com/group/android-developers?hl=en >> > > -- 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

