A couple of years ago I wrote an app that has an AccountManager. Now I'm re-organizing and cleaning up the code and I realized that
AccountManager.removeAccount(Account account, AccountManagerCallback<Boolean> callback, Handler handler)
is deprecated.
The documentation says that you have to use this method instead
AccountManager.removeAccount(Account account, Activity activity, AccountManagerCallback<Bundle> callback, Handler handler)
But the problem is that I need API 22 or grater to use it, and my app is API 14 or grater, so here's the question:
What can I do to use a non-deprecated method?
You can check which API is installed on the phone in use and use the appropriate SDK based on that.
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.
}