public void onReceive(Context context, Intent intent) {
    Log.e("auth failure receiver received");

    if (sIsHandling || !PrefUtil.getInstance(context).isLogined()) {
      return;
    }
    sIsHandling = true;

    PrefUtil.getInstance(context).logoutAccount();
    ManageAccountsActivity.deleteDatasInDB(context);
    Database database = new Database(context);
    database.close();
    // 变换Database,Connect2的标志位(用户判断是否切换了用户)
    Database.sFlagIndex++;
    Connect2.sFlagIndex++;

    // auth failure, don't need to logout.
    //        WowTalkWebServerIF mWeb = WowTalkWebServerIF.getInstance(context);
    //        mWeb.fLogout();
    WowTalkVoipIF.getInstance(context).fStopWowTalkService();
    Intent loginIntent = new Intent(context, LoginActivity.class);
    // android.util.AndroidRuntimeException: Calling startActivity() from outside of an Activity
    // context requires the FLAG_ACTIVITY_NEW_TASK flag. Is this really what you want?
    loginIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    loginIntent.putExtra(
        LoginActivity.EXTRA_PROMPT, context.getString(R.string.account_web_api_auth_failure));
    context.startActivity(loginIntent);

    if (null != StartActivity.instance()) {
      StartActivity.instance().finish();
    }
    sIsHandling = false;
  }
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.triplist);
    init();

    poiAdapter.notifyDataSetChanged();
    userLocation = StartActivity.verifyUserLocation(userLocation, this);
  } // onCreate
 // 重写back键
 @Override
 public boolean onKeyDown(int keyCode, KeyEvent event) {
   if (keyCode == KeyEvent.KEYCODE_BACK) {
     // LogUtils.e("LoginActivity",
     // "LocationUtils.activityList.size()="+LocationUtils.activityList.size());
     if (LocationUtils.activityList.size() == 0 || StartActivity.mTimer != null) {
       StartActivity.stopThread();
     }
     pressAgainExit();
     return true;
   }
   return super.onKeyDown(keyCode, event);
 }
Exemple #4
0
  @Override
  protected void onStart() {
    super.onStart();
    // restartTimer();
    /*
    if(ntpTrustedTime.hasCache()){
    	mHandler.removeMessages(UPDATE_TIME);
    	mHandler.sendEmptyMessage(UPDATE_TIME);
    }*/

    mHandler.removeMessages(UPDATE_TIME);
    mHandler.sendEmptyMessage(UPDATE_TIME);
    refreshTime();
  }
Exemple #5
0
 @Override
 protected void onStop() {
   mHandler.removeMessages(UPDATE_TIME);
   super.onStop();
   //	cancelTimer();
 }
Exemple #6
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    sp = new SharePreferenceUtils(this).getSP();
    SelectCtiyActivity.ocnc = this;
    SyncService.obc = this;
    FxService.osc = this;
    WheatherActivity.ost = this;
    mSpUtil = BaseApplication.getInstance().getSharePreferenceUtil();

    initRoot();
    initList();
    // initValues();
    initView();

    // content.setOnTouchListener(this);
    //	startService(new Intent(this.getApplicationContext(),TsaService.class));
    mHandler =
        new Handler() {

          final SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy/MM/dd");
          final SimpleDateFormat sdf2 = new SimpleDateFormat("HH:mm:ss");
          Date now = new Date();
          Date netDate = new Date();

          @Override
          public void handleMessage(Message msg) {
            if (msg.what == UPDATE_TIME) {
              // Calendar calendar = Calendar.getInstance();
              now.setTime(System.currentTimeMillis() - timeZoneOffset);
              setLocalAnitmation(now.getHours(), now.getMinutes(), now.getSeconds());
              local_time.setText(sdf2.format(now));
              local_date.setText(sdf1.format(now) + " " + invertWeekday(now.getDay()));

              if (ntpTrustedTime.hasCache()) {
                netDate.setTime(ntpTrustedTime.currentTimeMillis() - timeZoneOffset);
              } else {
                L.d("==非网络时间");
                netDate.setTime(System.currentTimeMillis() - timeZoneOffset);
              }
              setNetClockAnimation(netDate.getHours(), netDate.getMinutes(), netDate.getSeconds());
              net_time.setText(sdf2.format(netDate));
              net_date.setText(sdf1.format(netDate) + " " + invertWeekday(netDate.getDay()));

              mHandler.sendEmptyMessageDelayed(UPDATE_TIME, 200);
            }

            if (msg.what == 3) {
              settime_frequent_text.setText(getFrequentTime());
            }
            if (msg.what == 4) {
              content.setBackgroundResource(sp.getInt("background", R.drawable.bg_blue));
            }
            if (msg.what == 5) {
              WeatherInfo allWeather = BaseApplication.getInstance().getAllWeather();
              //					cityName.setText(allWeather.getCity());
              String s = "";
              if (!TextUtils.isEmpty(allWeather.getFeelTemp())) {
                s = s + allWeather.getFeelTemp() + "  ";
                mSpUtil.setSimpleTemp(
                    allWeather.getFeelTemp().replace("~", "/").replace("℃", "°")); // 保存一下温度信息,用户小插件
              } else if (!TextUtils.isEmpty(allWeather.getTemp0())) {
                s = s + allWeather.getTemp0() + "  ";
                mSpUtil.setSimpleTemp(allWeather.getTemp0().replace("~", "/").replace("℃", "°"));
              }

              String climate = allWeather.getWeather0();
              if (!TextUtils.isEmpty(climate)) {
                s = s + climate + "  ";
                mSpUtil.setSimpleClimate(climate); // 保存一下天气信息,用户小插件
              }

              String time = allWeather.getIntime();
              mSpUtil.setTimeSamp(TimeUtil.getLongTime(time)); // 保存一下更新的时间戳,记录更新时间
              if (!TextUtils.isEmpty(allWeather.getCity())) {
                s = s + allWeather.getCity() + " >";
                cityName.setText(s);
                cityName.setTextSize(17);
              }
            }
            /*
            if(msg.what==21){
            	ntpError();
            }*/
          }
        };
    new GetWeatherTask(mHandler, new City(null, mSpUtil.getCity(), null, mSpUtil.getPinyin(), null))
        .execute();

    if (!mSpUtil.getNtpService().equals("")) {
      currntTnp = mSpUtil.getNtpService();
    }

    setNtpText();
    updateTimeZoneOffset();

    initNtpTime();

    startService(this.getApplicationContext());
  }
 public void onBulkFollowComplete(String s, int i, String s1)
 {
     dismissDialog();
     StartActivity.toStart(FindFriendsNUXActivity.this, true);
     finish();
 }