/** This method clears the current account address and launches Login Activity */ public void logout() { // Remove current device on the backend so notifications are not sent to it ThreadManager.execute( new RemoveCurrentDeviceRunnable( (ZeppaApplication) getApplication(), getGoogleAccountCredential())); // Restore all singleton instances. EventTagSingleton.getInstance().restore(); NotificationSingleton.getInstance().restore(); ZeppaEventSingleton.getInstance().restore(); ZeppaUserSingleton.getInstance().restore(); // Clear logged in prefs getSharedPreferences(Constants.SHARED_PREFS, MODE_PRIVATE) .edit() .remove(Constants.LOGGED_IN_ACCOUNT) .commit(); getSharedPreferences(Constants.SHARED_PREFS, MODE_PRIVATE) .edit() .remove(Constants.LOGGED_IN_USER_ID) .commit(); // Return to Login activity Intent toLogin = new Intent(this, LoginActivity.class); startActivity(toLogin); finish(); }
@Override protected void onStart() { super.onStart(); if (!(this instanceof LoginActivity) && !(this instanceof NewAccountActivity) && ZeppaUserSingleton.getInstance().getUserMediator() == null) { Intent toLogin = new Intent(this, LoginActivity.class); startActivity(toLogin); finish(); } ((ZeppaApplication) getApplication()).setCurrentActivity(this); String heldAccountName = PrefsManager.getLoggedInEmail(getApplication()); if (!Constants.LOCAL_RUN && heldAccountName != null && !heldAccountName.isEmpty()) { initializeApiClient(heldAccountName); apiClient.connect(); } }