AccountManager.removeAccount 已弃用
AccountManager.removeAccount deprecated
几年前我写了一个有 AccountManager 的应用程序。现在我正在重新组织和清理代码,我意识到
AccountManager.removeAccount(Account account, AccountManagerCallback<Boolean> callback, Handler handler)
已弃用。
文档说你必须改用这个方法
AccountManager.removeAccount(Account account, Activity activity, AccountManagerCallback<Bundle> callback, Handler handler)
但问题是我需要 API 22 或更碎才能使用它,而我的应用程序是 API 14 或更碎,所以问题是:
如何使用未弃用的方法?
您可以检查正在使用的 phone 上安装了哪个 API,并根据此使用适当的 SDK。
if (android.os.Build.VERSION.SDK_INT >= 22) {
// use new account manager code
} else {
//noinspection deprecation
// use old account manager code, the above comment will omit the warning.
}
几年前我写了一个有 AccountManager 的应用程序。现在我正在重新组织和清理代码,我意识到
AccountManager.removeAccount(Account account, AccountManagerCallback<Boolean> callback, Handler handler)
已弃用。
文档说你必须改用这个方法
AccountManager.removeAccount(Account account, Activity activity, AccountManagerCallback<Bundle> callback, Handler handler)
但问题是我需要 API 22 或更碎才能使用它,而我的应用程序是 API 14 或更碎,所以问题是:
如何使用未弃用的方法?
您可以检查正在使用的 phone 上安装了哪个 API,并根据此使用适当的 SDK。
if (android.os.Build.VERSION.SDK_INT >= 22) {
// use new account manager code
} else {
//noinspection deprecation
// use old account manager code, the above comment will omit the warning.
}