Hi,
I am trying to implement an account provider with no success..I hope someone
could help me please..
First, this is my service and AccountAuthenticator class
namespace test
{
public class AccountAuthenticatorService : Service
{
private static AccountAuthenticator sAccountAuthenticator = null;
public static string ACCOUNT_TYPE = "com.test.account";
public static string ACCOUNT_NAME = "test";
private Context _context;
public AccountAuthenticatorService(Context _context)
: base()
{
this._context = _context;
}
public override IBinder OnBind(Intent intent)
{
IBinder ret = null;
if (intent.Action ==
Android.Accounts.AccountManager.ActionAuthenticatorIntent)
ret = getAuthenticator().IBinder;
return ret;
}
private AccountAuthenticator getAuthenticator()
{
if (sAccountAuthenticator == null)
sAccountAuthenticator = new AccountAuthenticator
(this._context);
return sAccountAuthenticator;
}
}
public class AccountAuthenticator :
Android.Accounts.AbstractAccountAuthenticator
{
private Context mContext;
public AccountAuthenticator(Context context)
: base(context)
{
mContext = context;
}
/*
* The user has requested to add a new account to the system. We
return an intent that will launch our login screen if the user has not
logged in yet,
* otherwise our activity will just pass the user's credentials on
to the account manager.
*/
public override Bundle
AddAccount(Android.Accounts.AccountAuthenticatorResponse response, string
accountType, string authTokenType, string[] requiredFeatures, Bundle
options)
{
try
{
Bundle result;
Intent intent;
intent = new Intent(this.mContext,
typeof(eGestionaMobile.Actividades.Login));
intent.PutExtra(AccountManager.KeyAccountAuthenticatorResponse, response);
result = new Bundle();
result.PutParcelable(AccountManager.KeyIntent, intent);
return result;
}
catch (Exception ex)
{
throw ex;
}
}
}
Second, my AndroidManifest
<service android:name="test.AccountAuthenticatorService"
android:exported="true" android:process=":auth">
<intent-filter>
<action android:name="android.accounts.AccountAuthenticator">
</action>
</intent-filter>
<meta-data android:name="android.accounts.AccountAuthenticator"
android:resource="@xml/authenticator">
</meta-data>
</service>
Third, authenticator xml in resources --> Xml
<?xml version="1.0" encoding="utf-8"?>
<account-authenticator
xmlns:android="http://schemas.android.com/apk/res/android"
android:accountType="com.test.account"
android:icon="@drawable/icon"
android:smallIcon="@drawable/icon"
android:label="egestionamobile"
android:accountPreferences="@xml/account_preferences"
/>
4Th, My login activity
On my login button I have..
_account = new Account(AccountAuthenticatorService.ACCOUNT_NAME,
AccountAuthenticatorService.ACCOUNT_TYPE);
_accountmanager = AccountManager.FromContext(this);
Bundle _datosUsuario = new Bundle();
_datosUsuario.PutString("test", _usuario);
bool _accountCreated =
_accountmanager.AddAccountExplicitly(_account, null, _datosUsuario);
The error it gives me is "caller uid XXXX is different than the
authentication uid"
I have been looking for some info and as I have seen.. it might be my
account type don`t match with my authenticators.xml.. but it`s the same..
I have debugg it and it doesn´t come in my service so I think my manifest
service does not link with my service...
Any ideas about all this? Thanks in advance!!
--
View this message in context:
http://mono-for-android.1047100.n5.nabble.com/Android-Account-Provider-tp5711848.html
Sent from the Mono for Android mailing list archive at Nabble.com.
_______________________________________________
Monodroid mailing list
[email protected]
UNSUBSCRIBE INFORMATION:
http://lists.ximian.com/mailman/listinfo/monodroid