Search code examples
androidparse-platformandroid-syncadapter

Android,What is the best way to kill AbstractThreadedSyncAdapter?


I'm using SyncAdapter in my application. My problem is if I log out and then call ContentResolver.requestSync(myAccount, MyProvider.AUTHORITY, settingsBundle); it still calls the parse cloud based on previous parse user data.

But before log out I clear all my database and I make sure after ParseUser.logout(); it returns null as the current user. But when I requestSync as follows

@Override
public void onPerformSync(Account account, Bundle extras, String authority, ContentProviderClient provider, SyncResult syncResult) {
    Log.d("Current user",ParseUser.getCurrentUser().getObjectId());
}

it shows the id of previous user. What is the best way to stop sync adapter and once again start it from top so that it wont have my user id?

I tried ContentResolver.cancelSync(myAccount, MyProvider.AUTHORITY); to stop sync, but it still shows the user id. Can anybody help me to solve this and thanks in advance.


Solution

  • Remove and add account. accountManager.removeAccount() well this is depricated but give a try.