예제 #1
0
  private void firstEnter() {

    if (mLiteBlueService != null) {

      // 确认蓝牙
      if (!mLiteBlueService.isEnable()) {
        showIosDialog();
      } else {
        if (mLiteBlueService.isBinded()) { // 当本地绑定时,开启搜索。
          mLiteBlueService.startScanUsePeriodScanCallback();
        }
      }
    }

    // 加载天气
    LoadWeatherJsonTask taskFirst = new LoadWeatherJsonTask(MSG_FORECAST, this, mHandler);
    taskFirst.setOnProgressChangeListener(this);
    String city = (String) SharedPreferenceUtil.get(this, Constant.SHARE_PLACE, "beijing");
    if (!city.equals("")) {
      taskFirst.execute(YahooUtil.getForecastUrl(city));
      tvWeatherAddress.setText(city);
    } else {

    }
  }
예제 #2
0
  @Override
  protected void onResume() {
    // if
    // (mSimpleBlueService.getConnectState()==BluetoothProfile.STATE_CONNECTED)
    // {
    if (mLiteBlueService != null) {

      if (mLiteBlueService.isBinded() && mLiteBlueService.isServiceDiscovered()) {
        mHandler.post(runRssi);
      }
    }
    setClockTime();
    super.onResume();
  }
예제 #3
0
 @Override
 protected void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   setContentView(R.layout.activity_main);
   mLiteBlueService = getLiteBlueService();
   // mSimpleBlueService = getSimpleBlueService();
   initViews();
   setListener();
   registerReceiver(mReceiver, LiteBlueService.getIntentFilter());
   firstEnter();
   runRssi =
       new Runnable() {
         @Override
         public void run() {
           Log.v("", "______请求rssi_______");
           mLiteBlueService.readRemoteRssi();
           mHandler.sendEmptyMessage(MSG_RUN);
         }
       };
 }