Beispiel #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();
  }
Beispiel #2
0
 @Override
 protected void onResume() {
   SharedPreferences settings = getSharedPreferences(PREF_TITLE, 0);
   if (settings.getBoolean(PREF_BACKGROUND, DEFAULT_BACKGROUND) == true) {
     TextView tv_background = (TextView) findViewById(R.id.status_textView_background);
     tv_background.setText("RUN IN BACKGROUND");
   }
   super.onResume();
 }
Beispiel #3
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    SharedPreferences settings = getSharedPreferences(PREF_TITLE, 0);
    setContentView(R.layout.activity_status);
    Log.i("LC", "Status: onCreate");

    Intent intent = new Intent(getApplicationContext(), MinerService.class);
    startService(intent);
    bindService(intent, super.mConnection, Context.BIND_AUTO_CREATE);

    Button btn_startStop = (Button) findViewById(R.id.status_button_startstop);

    // Setup nav spinner
    Spinner spn_nav = (Spinner) findViewById(R.id.status_spinner_nav);
    ArrayAdapter<?> adapter =
        ArrayAdapter.createFromResource(this, R.array.nav, android.R.layout.simple_spinner_item);
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    spn_nav.setAdapter(adapter);
    spn_nav.setSelection(0);
    spn_nav.setOnItemSelectedListener(new SpinnerListener(0));

    // Set Button Click Listener
    btn_startStop.setOnClickListener(
        new Button.OnClickListener() {

          public void onClick(View v) {
            Button b = (Button) v;

            if (b.getText().equals(getString(R.string.status_button_start)) == true) {
              startMining();
              b.setText(getString(R.string.main_button_stop));
            } else {
              stopMining();
              b.setText(getString(R.string.status_button_start));
            }
          }
        });

    updateThread.start();

    // Launch news on first run
    if (settings.getBoolean(PREF_NEWS_RUN_ONCE, false) == false) {
      intent = new Intent(getApplicationContext(), NewsActivity.class);
      startActivity(intent);
    }
  }
Beispiel #4
0
  @Override
  protected void onPause() {
    // TODO Auto-generated method stub

    super.onPause();
  }