i have implemented accounts app following tutorial http://blog.udinic.com/2013/04/24/write-your-own-android-authenticator/
every aspect of implementation works great except when try remove account following code:
public void logout(view view) { // remove account , restart app stopservice(new intent(this, serversync.class)); account account = accountmanager.get(this).getaccountsbytype(constants.account_type)[0]; final accountmanagerfuture<bundle> future = accountmanager.get(this).removeaccount(account, this, new accountmanagercallback<bundle>() { @override public void run(accountmanagerfuture<bundle> future) { try { future.getresult(); } catch (exception e) { e.printstacktrace(); } { intent intent = getbasecontext().getpackagemanager() .getlaunchintentforpackage(getbasecontext().getpackagename()); intent.addflags(intent.flag_activity_clear_top); finish(); startactivity(intent); } } }, null); } when called produces
nosuchmethoderror: android.accounts.accountmanager.removeaccount and app crashes.
i have followed android documentation
http://developer.android.com/reference/android/accounts/accountmanager.html
and app has correct permissions etc. tried overriding getaccountremovalallowed in accountauthenticator, forcing return true.
is there other information missing android documentation?
the version of removeaccount using introduced api leve 22 , using on version of android older it. should check current version @ runtime , use deprecated version of removeaccount devices version of android older 22
removeaccount (account account, accountmanagercallback callback, handler handler)
if (build.version.sdk_int < 22) { accountmanager.get(this).removeaccount(account, new accountmanagercallback<bundle>(){....}, null) } else { // version using }
Comments
Post a Comment