Пример #1
0
  @Override
  protected void onStop() {
    // TODO Auto-generated method stub
    if (updateThread.isAlive() == true) {
      updateThread.interrupt();
    }

    SharedPreferences settings = getSharedPreferences(PREF_TITLE, 0);
    if (settings.getBoolean(PREF_BACKGROUND, DEFAULT_BACKGROUND) == false) {
      if (mService.running == true) {
        stopMining();
      }
      Intent intent = new Intent(getApplicationContext(), MinerService.class);
      stopService(intent);
    }

    Log.i("LC", "Main: in onStop()");
    try {
      unbindService(mConnection);
    } catch (RuntimeException e) {
      Log.i("LC", "RuntimeException:" + e.getMessage());
      // unbindService generates a runtime exception sometimes
      // the service is getting unbound before unBindService is called
      // when the window is dismissed by the user, this is the fix
    }

    super.onStop();
  }