How my app can know when user logout from its native Facebook app ?
I am using below code for Logging out from Facebook in my app. And it is working fine.
Try to check if there's a Facebook account in the system.
AccountManager accountManager = AccountManager.get(context);
Account[] facebookAccounts = accountManager.getAccountsByType("com.facebook.auth.login");
if (facebookAccounts.length > 0) {
facebook.logout(getApplicationContext());
...
}
Yes, the code contains hard-coded account type, which is slightly unreliable due to possible changes in the native app, though the probability of such changes is very small.
And don't forget to add a GET_ACCOUNTS permission to the Manifest.