Dan, My code and yours both work on the Droid, but there are some nasty side-effects. After adding an account with your application (or mine) whenever you visit the "Accounts & Sync" settings screen, the system crashes hard and reboots.
11-23 13:21:34.863: WARN/dalvikvm(1011): threadid=13: thread exiting with uncaught exception (group=0x4001b180) 11-23 13:21:34.863: ERROR/AndroidRuntime(1011): Uncaught handler: thread android.server.ServerThread exiting due to uncaught exception 11-23 13:21:34.879: ERROR/AndroidRuntime(1011): *** EXCEPTION IN SYSTEM PROCESS. System will crash. 11-23 13:21:34.879: ERROR/AndroidRuntime(1011): java.lang.NullPointerException 11-23 13:21:34.879: ERROR/AndroidRuntime(1011): at com.android.settings.ManageAccountsSettings.onSyncStateUpdated (ManageAccountsSettings.java:187) 11-23 13:21:34.879: ERROR/AndroidRuntime(1011): at com.android.settings.ManageAccountsSettings.onAccountsUpdated (ManageAccountsSettings.java:244) 11-23 13:21:34.879: ERROR/AndroidRuntime(1011): at android.accounts.AccountManager$10.run(AccountManager.java:389) 11-23 13:21:34.879: ERROR/AndroidRuntime(1011): at android.os.Handler.handleCallback(Handler.java:587) 11-23 13:21:34.879: ERROR/AndroidRuntime(1011): at android.os.Handler.dispatchMessage(Handler.java:92) 11-23 13:21:34.879: ERROR/AndroidRuntime(1011): at android.os.Looper.loop(Looper.java:123) 11-23 13:21:34.879: ERROR/AndroidRuntime(1011): at com.android.server.ServerThread.run(SystemServer.java:428) I'm looking at the source now to see if I can figure out what's going on. If necessary, I'll file a case with the project if I find a bug in the Android source. Cheers, Jerry On Nov 23, 8:18 am, Jerry Brady <[email protected]> wrote: > I'm going to be trying it on a Droid this morning. > > On Nov 21, 10:07 pm, Dan Dumont <[email protected]> wrote: > > > > > I get that exception in the emulator ( doesn't reboot though ) > > > I thought it was due to missing pieces of the emulator... > > > does logcat output anything? > > > On Sat, Nov 21, 2009 at 7:07 PM, NitroDesk <[email protected]> wrote: > > > Any of you folks tried this on a Droid? > > > Simply installing the project that contains an Authenticator in the > > > manfest and the other related items seems to cause the "Add Account" > > > option in the account list on te droid to simply reoot the phone with > > > an exception. > > > Anyone else seen this or find a way to avoid this ? > > > -g > > > > On Nov 21, 9:04 am, Jerry Brady <[email protected]> wrote: > > > > Dan, > > > > > Now I see what you are doing in your code and found the reference to > > > > AddAccountExplicitly(). I want to skip returning an intent to fire > > > > the an AccountAuthenticatorActivity and instead to return > > > > KEY_ACCOUNT_NAME and KEY_ACCOUNT_TYPE directly from my > > > > AbstractAccountAuthenticator's addAccount method whereas your code > > > > returns an intent that fires your authentication activity. > > > > > The main issue for me so far is that I don't see that my > > > > AbstractAccountAuthenticator is ever being instantiated. > > > > > Cheers, > > > > Jerry > > > > > On Nov 20, 7:53 am, Dan Dumont <[email protected]> wrote: > > > > > > Yes. But I make the AddAccountExplicitly call in my Authenticator. > > > You > > > > > use theAccountManagerto 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 anAccountAuthenticatorhandle the storage and dirty bits > > > > > >> > >> of > > > the > > > > > >> actual > > > > > >> > >> authentication and credential storage. > > > > > > >> > >> You will need to create anAccountAuthenticatorfrom 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; > > > > > >> > >> } > > > > > > >> > >> privateAccountAuthenticatorgetSametimeAuthenticator() { > > > > > >> > >> if (_aa == null) > > > > > >> > >> _aa = newAccountAuthenticator(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 yourAccountAuthenticator: > > > > > > >> > >> 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... > > read more » -- 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

