public void logout() { if (mMockParse != null) { mMockParse.setIsLoggedIn(false); if (isInstrumentationTest()) { LocationTrackingService.stop(); EventBus.getDefault() .post(new LogoutEvent(null)); } } else { ParseUser.logOutInBackground(new LogOutCallback() { @Override public void done(ParseException e) { if (e != null) { EventBus.getDefault() .post(new LogoutEvent(e)); } else { LocationTrackingService.stop(); EventBus.getDefault() .post(new LogoutEvent(null)); } } }); } }
private void actuallyLogout() { final ProgressDialog pd = new ProgressDialog(getContext()); pd.setMessage(getContext().getString(R.string.performingLogout)); pd.setCancelable(false); pd.show(); ParseUser.logOutInBackground(new LogOutCallback() { @Override public void done(ParseException e) { pd.dismiss(); pd.cancel(); if(e != null) { Toast.makeText(getContext(), getContext().getString(R.string.performedLogoutError), Toast.LENGTH_LONG).show(); } else { Toast.makeText(getContext(), getContext().getString(R.string.performedLogoutSuccess), Toast.LENGTH_SHORT).show(); LoginManager.getInstance().logout(); ((MainActivity) getActivity()).updateDrawer(); ((MainActivity)getActivity()).openDrawer(); ((MainActivity)getActivity()).setupEventFragment(); } } }); }
@Override public boolean onOptionsItemSelected(MenuItem item) { // Handle action bar item clicks here. The action bar will // automatically handle clicks on the Home/Up button, so long // as you specify a parent activity in AndroidManifest.xml. int id = item.getItemId(); //noinspection SimplifiableIfStatement if (id == R.id.action_signout) { ParseUser.logOutInBackground(new LogOutCallback() { @Override public void done(ParseException e) { if(e == null){ Intent i = new Intent(getApplicationContext(), SignOnActivity.class); startActivity(i); finish(); } else{ //couldn't log out e.printStackTrace(); } } }); return true; } return super.onOptionsItemSelected(item); }
/** * Logs out the current user and starts the new account activity. * Just starts the new account activity is no user is logged in */ private void logout(){ ParseUser.logOutInBackground(new LogOutCallback() { @Override public void done(ParseException e) { if(e == null){ startLoginActivity(); } else{ updateToast(e.getMessage(), Toast.LENGTH_LONG); } } }); }
@Override public boolean onOptionsItemSelected(MenuItem item) { // Handle action bar item clicks here. The action bar will // automatically handle clicks on the Home/Up button, so long // as you specify a parent activity in AndroidManifest.xml. int id = item.getItemId(); if (id == R.id.action_settings) { Intent newGoalIntent = new Intent(this, SettingsActivity.class); startActivityForResult(newGoalIntent, SETTINGS_REQUEST); return true; } if (id == R.id.action_sign_out) { ParseUser.logOutInBackground(new LogOutCallback() { @Override public void done(ParseException e) { // Show a simple Toast message upon successful registration Toast.makeText(BaseActivity.this, "Signing out...", Toast.LENGTH_LONG).show(); // Send user to LauncherActivity.class Intent intent = new Intent(BaseActivity.this, LauncherActivity.class); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(intent); } }); return true; } return super.onOptionsItemSelected(item); }