@Override protected Integer doInBackground(String... params) { HttpDelete request = new HttpDelete(Cashpoint.ENDPOINT + "/auth?auth_token=" + session.getAuthtoken()); try { HttpResponse response = Cashpoint.getHttpClient().execute(request); int statusCode = response.getStatusLine().getStatusCode(); // if (statusCode != 200) { // Log.e(this.getClass().getSimpleName(), // (new BasicResponseHandler().handleResponse(response))); // } return statusCode; } catch (IOException e) { Log.e(this.getClass().getSimpleName(), e.toString()); error = e; } return 0; }
@Override protected void onPostExecute(Integer status) { dialog.dismiss(); // if (status == 200) { // Toast.makeText(context, context.getString(R.string.logout_success), // Toast.LENGTH_SHORT).show(); //// context.finish(); // } else if (status == 200 || status == 401) { Session.getInstance().destroy(); // see // http://stackoverflow.com/questions/3007998/on-logout-clear-activity-history-stack-preventing-back-button-from-opening-lo Intent intent = new Intent(context, LoginActivity.class); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); intent.putExtra("signedoff", true); context.startActivity(intent); } else { Toast.makeText(context, context.getString(R.string.logout_fail), Toast.LENGTH_SHORT).show(); } }