public void doExpireLogin() { // //////////////////////////////////// BaseActivity.exit(); deInit(); // ///////////////////////////////////// setLogin(false); Intent toLogin = new Intent(this, LoginActivity.class); toLogin.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); toLogin.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); toLogin.putExtra(LoginActivity.ARG_KEY_LOGIN_EXPIRE, "登录过期,请重新登录。"); startActivity(toLogin); }
public NetworkState httpDeleteUpdateString(String uri, JSONParseInterface jsonParser) { NetworkState netState = new NetworkState(); // if(wapIf()){ // uri="http://"+CMWAP_GATEWAY+uri.substring(uri.indexOf("/", 8)); // } int stateCode; HttpDelete httpDelete = new HttpDelete(uri); httpDelete.setHeader( "Accept-Language", (Locale.getDefault().getLanguage() + "-" + Locale.getDefault().getCountry()).toLowerCase()); if (JSESSIONIDStr != null) { httpDelete.setHeader("Cookie", "JSESSIONID=" + JSESSIONIDStr); } httpDelete.setHeader("Content-Type", "application/json"); try { HttpResponse httpResponse = defaultHttpClient.execute(httpDelete); stateCode = httpResponse.getStatusLine().getStatusCode(); if (stateCode != 200) { netState.setNetworkState(false); netState.setErrorMessage(NetworkState.ERROR_SERVER_ERROR_MESSAGE); // Log.d("NETT", NetworkState.ERROR_SERVER_ERROR_MESSAGE+":"+stateCode+uri); return netState; } getCookie(defaultHttpClient); HttpEntity httpEntity = httpResponse.getEntity(); InputStream is = null; if (httpResponse.getEntity().getContentEncoding() == null || httpResponse.getEntity().getContentEncoding().getValue().toLowerCase().indexOf("gzip") < 0) { is = new ByteArrayInputStream(EntityUtils.toByteArray(httpEntity)); } else { is = new GZIPInputStream(new ByteArrayInputStream(EntityUtils.toByteArray(httpEntity))); } byte[] con = readInStream(is); String str = new String(con); if (str != null && str.indexOf("登录过期") != -1 && str.indexOf("-202") != -1) { if (appContext instanceof BaseActivity) { BaseActivity ba = ((BaseActivity) appContext); ////////////////////////////////////// ba.exit(); ba.deInit(); /////////////////////////////////////// new Thread() { public void run() { // 停掉连接obd Intent intent = new Intent(); intent.setAction(TongGouService.TONGGOU_ACTION_START); intent.putExtra("com.tonggou.server", "STOP"); appContext.sendBroadcast(intent); } }.start(); Intent toLogin = new Intent(appContext, LoginActivity.class); toLogin.putExtra("tonggou.loginExpire", "登录过期,请重新登录。"); toLogin.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); appContext.startActivity(toLogin); } } jsonParser.parsing(str); // 解析 netState.setNetworkState(true); return netState; } catch (IOException ie) { netState.setNetworkState(false); ie.printStackTrace(); if (ie instanceof SocketTimeoutException) { if ("en".equals(Locale.getDefault().getLanguage().toLowerCase())) { netState.setErrorMessage(NetworkState.ERROR_CLIENT_ERROR_SOCKETTIMEOUT_MESSAGE_EN); } else { netState.setErrorMessage(NetworkState.ERROR_CLIENT_ERROR_SOCKETTIMEOUT_MESSAGE); } return netState; } if ("en".equals(Locale.getDefault().getLanguage().toLowerCase())) { netState.setErrorMessage(NetworkState.ERROR_CLIENT_ERROR_TIMEOUT_MESSAGE_EN); } else { netState.setErrorMessage(NetworkState.ERROR_CLIENT_ERROR_TIMEOUT_MESSAGE); } } catch (FactoryConfigurationError e) { netState.setNetworkState(false); netState.setErrorMessage(NetworkState.ERROR_RESPONSE_ERROR_MESSAGE); } catch (NullPointerException ex) { netState.setNetworkState(false); netState.setErrorMessage(NetworkState.ERROR_RESPONSE_ERROR_MESSAGE); } return netState; }