Skip to content

Broadcast event to logout current user from CommCare

Shubham Goyal edited this page May 12, 2021 · 2 revisions

CommCare can auto-logout the user based on the broadcast event -

Intent i = new Intent("org.commcare.dalvik.api.action.CommCareLogoutAction");
i.setComponent(new ComponentName("org.commcare.dalvik.debug",
                "org.commcare.provider.CommCareLogoutReceiver"));
sendBroadcast(i);

To be able to fire this broadcast, your app needs to request for the permission org.commcare.dalvik.permission.COMMCARE_LOGOUT. This is a dangerous permission and hence must be requested at the runtime. Refer to Android docs on requesting runtime permissions for more details.

This change is only implemented in CommCare version 2.52 and above.