I'm using accountmanager
in my application.
I check first for an account, to see if it exists. if it does not, it is added explicitly. The Code crashes in addaccountexplicitly()
Account[] accounts = AccountManager.get(this).getAccountsByType(getString(R.string.authtype));
if(accounts.length==1)
{
Toast.makeText(this,accounts[0].name,Toast.LENGTH_SHORT).show();
Intent i = new Intent(Splash.this, MapsActivity.class);
startActivity(i);
finish();
}
else
{
boolean accountCreated = mAccountManager.addAccountExplicitly(new Account("sasa",getString(R.string.authtype)), "", null);
Intent i = new Intent(Splash.this, MainActivity.class);
startActivity(i);
finish();
}
Crash Log
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2464)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2524)
at android.app.ActivityThread.access$900(ActivityThread.java:154)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1391)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:224)
at android.app.ActivityThread.main(ActivityThread.java:5526)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
Caused by: java.lang.SecurityException: uid 10149 cannot explicitly add accounts of type: com.rakebny.musta.authtype
at android.os.Parcel.readException(Parcel.java:1627)
at android.os.Parcel.readException(Parcel.java:1579)
at android.accounts.IAccountManager$Stub$Proxy.addAccountExplicitly(IAccountManager.java:890)
at android.accounts.AccountManager.addAccountExplicitly(AccountManager.java:722)