1

I am trying to add my App into the account manager of android in a Xamarin Droid project, so that user doesn't have to enter the username and password every time.

In my MainActivity, i pass in ApplicationContext object to the App class. Inside the App class i store the reference of ApplicationContext, and then when i call AccountManager.Get (applicationManger).GetAccounts (), it always returns an array of 0 Accounts. When i try to add an Account using

Account acc = new Account ("MyApp", "com.test");
applicationManger.AddAccountExplicitly (acc, "test", new Android.OS.Bundle());

i get the below error

Java.Lang.SecurityException: caller uid 10059 is different than the authenticator's uid

I am trying to understand how to get the authenticator uid to match with my app'uid (10059). I have GET_ACCOUNTS, MANAGE_ACCOUNTS and AUTHENTICATE_ACCOUNTS permissions in the manifest.

asb
  • 781
  • 2
  • 5
  • 23
  • http://stackoverflow.com/questions/3774282/securityexception-caller-uid-xxxx-is-different-than-the-authenticators-uid – puj Mar 14 '15 at 23:06
  • I have gone through the above solution, but the answer is based on Sync Adapter example which i am not able to replicate into my solution which is a Xamarin forms application. Hopefully, i just need to correct my account type, but not sure where to look for. Also possibly i am setting the context wrong. – asb Mar 14 '15 at 23:12
  • Can we see your Manifest, or Authenticator you have declared? – puj Mar 14 '15 at 23:19
  • Okay, do you have an `account-authenticator` decalred anywhere? – puj Mar 14 '15 at 23:21
  • no, i don't have one – asb Mar 14 '15 at 23:22

1 Answers1

0

You will be needing something like this:

<?xml version="1.0" encoding="utf-8" ?>
<account-authenticator
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:icon="@drawable/myApp_icon"
    android:smallIcon="@drawable/myapp_icon"
    android:label="@string/AppName"        
    android:accountType="com.test.myaccounttype"/>
puj
  • 770
  • 5
  • 9
  • Didn't work, I added the above in my manifest. In the code i setup the account like Account acc = new Account ("MyApp", "com.test.myaccounttype"). when i try to add, I still i get the same error. – asb Mar 14 '15 at 23:36