コード例 #1
0
  @Override
  public void onCreate() {
    super.onCreate();

    // 初始化上下文工具
    ContextUtil.init(this);
    Log.d(TAG, "onCreate");
    // 建立http client
    mHttpClient = AbstractHttpApi.createHttpClient();
    // 初始化崩溃捕获处理
    crashHandler = CrashHandler.getInstance();
    crashHandler.init(getApplicationContext());
    try {
      // 发送崩溃日志
      crashHandler.sendPreviousReportsToServer();
    } catch (Throwable e) {
      e.printStackTrace();
    }
    try {
      DbHelper dbHelper = new DbHelper(getApplicationContext(), "rescueWorker.db", null, 1);
      Settings.dbHelper = dbHelper;
    } catch (Exception e) {
      e.printStackTrace();
    }
    // 初始化全局变量
    Settings.ASS_PATH = getPackageResourcePath();
    Settings.DEV_ID = ActivityUtil.getDeviceId(this);
    Settings.VERSION_NAME = ActivityUtil.getVersionName(this);

    // 重置配置信息
    resetConfig();

    // 推送服务
    new Handler() {
      @Override
      public void handleMessage(Message msg) {
        Intent intentService = new Intent(ContextUtil.getContext(), KeepAliveService.class);
        ContextUtil.getContext().startService(intentService);
      }
    }.sendEmptyMessageDelayed(0, 1000);
    // 定位
    LocationUtil.getInstance().init();
    LocationUtil.getInstance().start();
    // Log.e("ActivityUtil.getRealDeviceId",ActivityUtil.getRealDeviceId(this));
  }
コード例 #2
0
 @Override
 protected void onResume() {
   super.onResume();
   Settings.CURRENT_PAGE = this.getClass().getSimpleName();
   // 判断是否已登录
   boolean hasLogined = SessionManager.getInstance().isUserLogin(this);
   // 没有登录,跳登录
   if (!hasLogined && !(this instanceof UserLoginActivity)) {
     ActivityUtil.jump(this, UserLoginActivity.class, 1, null, true);
     finish();
   }
 }
コード例 #3
0
  /** 创建Menu */
  @Override
  public boolean onCreateOptionsMenu(Menu menu) {
    if (ActivityUtil.isTestDev(this)) {
      DialogUtil.showDialog(
          this,
          R.layout.dialog_request_log,
          new DialogEventListener() {

            @Override
            public void onInit(View contentView, PopupWindow dialog) {
              TextView text = (TextView) contentView.findViewById(R.id.log);
              text.setText(Settings.requestLog.toString());
            }
          });
    }
    return false;
  }