Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/jenkins/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 如何以编程方式从移动设备中删除google帐户_Android_Google Account - Fatal编程技术网

Android 如何以编程方式从移动设备中删除google帐户

Android 如何以编程方式从移动设备中删除google帐户,android,google-account,Android,Google Account,我想从我的应用程序中单击一个按钮就删除google帐户,但我遇到了以下安全异常,此时应用程序崩溃。因此,如果有任何可能的方法,请指导我 java.lang.SecurityException: uid 10511 cannot remove accounts of type: com.google 这是我正在使用的代码 public static void removeAccount(Context mContext){ AccountManager am = Account

我想从我的应用程序中单击一个按钮就删除google帐户,但我遇到了以下安全异常,此时应用程序崩溃。因此,如果有任何可能的方法,请指导我

java.lang.SecurityException: uid 10511 cannot remove accounts of type: com.google
这是我正在使用的代码

 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);
        }
    }

提前感谢您的帮助。

您找到解决方案了吗?我也在寻找这种类型的解决方案,如果有人发现了这个问题,请告诉我