Exemplo n.º 1
0
  /** @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();
  }
Exemplo n.º 2
0
  /** 初始化配置 */
  public void onCreate() {
    super.onCreate();
    initConfig();
    initStores();
    initServices();
    initHandlers();
    initPosts();

    httpClient = createHttpClient();
    // 初始化自定义Activity管理器
    activityManager = ActivityManager.getScreenManager();
    CrashReport crashReport = new CrashReport();
    crashReport.start(this);

    // 初始化图片管理器
    final int memClass =
        ((android.app.ActivityManager) getSystemService(Context.ACTIVITY_SERVICE)).getMemoryClass();
    // Use 1/8th of the available memory for this memory cache.
    final int cacheSize = 1024 * 1024 * memClass / 8;
    AsyncImageManager.buildInstance(new LruImageCache(cacheSize));

    // 效能监控启动定时器代码

    mHandler.removeCallbacks(mUpdateTimeTask);
    mHandler.postDelayed(mUpdateTimeTask, 60000);
    int days = Preferences.getDayTime(sharePref);
    FileCopeTool.scanFilesAndDeleteAtpath(days);
  }
Exemplo n.º 3
0
  /** 用户注销 */
  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);
  }