/** @return 退出应用操作 */ public void exitApp() { try { log.debug("exit app and disconnect xmpp.."); hasLogined = false; notificationService.disconnect(getChatManager()); } catch (Exception e) { log.error("disconnect xmpp error!", e); } new AsyncTask<String, Integer, String>() { @Override protected String doInBackground(String... params) { MucManager.getInstanse(Application.this).offLine(); return null; } }.execute(); ThreadPlatformUtils.shutdownAllTask(); IMModelManager.instance().clear(); boolean outline = Preferences.getOutLine(Application.sharePref); if (!outline) { CubeApplication application = getCubeApplication(); application.save(application); } LoginModel.instance().clear(); activityManager.popAllActivity(); }
/** 用户注销 */ public void logOff() { try { log.debug("exit app and disconnect xmpp.."); hasLogined = false; notificationService.disconnect(getChatManager()); } catch (Exception e) { log.error("disconnect xmpp error!", e); } MucManager.getInstanse(this).offLine(); showTopWindow(a); ThreadPlatformUtils.shutdownAllTask(); Intent in = new Intent(BroadcastConstans.CANCEELDIOLOG); sendBroadcast(in); IMModelManager.instance().clear(); boolean outline = Preferences.getOutLine(Application.sharePref); if (!outline) { CubeApplication application = getCubeApplication(); application.save(application); } LoginModel.instance().clear(); Intent i = null; if (PadUtils.isPad(this)) { i = new Intent(); i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); i.setClass(this, FacadeActivity.class); i.putExtra("direction", 1); i.putExtra("type", "web"); i.putExtra("isPad", true); i.putExtra("value", "file:///android_asset/www/pad/login.html"); } else { // i = new Intent(); // i.setClass(this, LoginActivity.class); // i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); // i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); i = new Intent(); i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); i.setClass(this, FacadeActivity.class); i.putExtra("value", URL.PHONE_LOGIN_URL); i.putExtra("isPad", false); } activityManager.popAllActivity(); // activityManager.popAllActivityExceptOne(FacadeActivity.class); startActivity(i); }
private void initConfig() { initWebUrls(); EventBus.registerApp(this); /** 获取SharedPreferences对象 */ sharePref = PreferenceManager.getDefaultSharedPreferences(this); Boolean b = Preferences.getFirsttime(Application.sharePref); // 判断是不是第一次安装应用, CubeApplication app = CubeApplication.getInstance(this); app.loadApplication(); this.setCubeApplication(app); app.loadLocalModule(); // 同步前先显示ui CubeModuleManager.getInstance().init(CubeApplication.getInstance(this)); // 注册 EventBus.getEventBus(TmpConstants.EVENTBUS_COMMON) .register(originalParser = new OriginalParser(this)); EventBus.getEventBus(TmpConstants.EVENTBUS_COMMON).register(this); EventBus.getEventBus(TmpConstants.EVENTBUS_COMMON) .register(mdmSubsrcriber = new MdmSubsrcriber(this)); // 开启定位 new GeoManager(this.getApplicationContext()); }
/** 更新用户标签 */ public void refreshRegisrer() { String privileges = Preferences.getPrivileges(Application.sharePref); if (privileges == null || privileges.equals("")) { return; } String mytag = ""; try { JSONArray privs = new JSONArray(privileges); for (int i = 0; i < privs.length(); i++) { String name = privs.getJSONObject(i).getString("name"); if (name != null && !name.equals("")) { mytag += name + ","; } } } catch (JSONException e1) { e1.printStackTrace(); } List<NameValuePair> values = new ArrayList<NameValuePair>(); String names = getPackageName(); values.add(new BasicNameValuePair("deviceId", DeviceInfoUtil.getDeviceId(this))); values.add(new BasicNameValuePair("appId", cubeApplication.getAppKey())); String username = Preferences.getUserName(Application.sharePref); String sex = Preferences.getSex(Application.sharePref) != null ? Preferences.getSex(Application.sharePref) : ""; String phone = Preferences.getPhone(Application.sharePref); // 去掉了标签的userName,phone values.add(new BasicNameValuePair("alias", username)); values.add(new BasicNameValuePair("tags", "{privileges=" + mytag + "sex=" + sex + "}")); HttpPut request = new HttpPut(URL.CHECKIN_URL + "/tags"); request.setHeader( "Accept", "application/x-www-form-urlencoded, application/xml, text/html, text/*, image/*, */*"); DefaultHttpClient client = new DefaultHttpClient(); if (values != null && values.size() > 0) { try { UrlEncodedFormEntity entity; entity = new UrlEncodedFormEntity(values, "utf-8"); request.setEntity(entity); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } } try { HttpResponse response = client.execute(request); int statusCode = response.getStatusLine().getStatusCode(); if (statusCode != 200) { return; } } catch (ClientProtocolException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } }