3

I want to remove google account on a button click from my app but i'm getting following security exception and the app crashes at this point.So please guide me if there is any possible way to do this.

java.lang.SecurityException: uid 10511 cannot remove accounts of type: com.google

Here is my code that i'm using

 public static void removeAccount(Context mContext){
        AccountManager am = AccountManager.get(mContext);
        MainActivity activity;
        activity=(MainActivity)mContext;
        Handler handler=new Handler();
        Account[] accounts = am.getAccounts();

        if (accounts.length > 0) {
            Account accountToRemove = accounts[0];
            am.removeAccount(accountToRemove, null, null);
        }
    }

Thankx in advance for any help.

0 Answers0