@Override public int onStartCommand(Intent intent, int flags, int startId) { if (intent != null && (Intent.ACTION_DELETE.equals(intent.getAction()) || Intent.ACTION_INSERT.equals(intent.getAction()) && intentProcessed)) { Log.d(LOG, "Service got shutdown intent"); Ntf.show(this, false); stopSelf(); intentProcessed = true; return START_NOT_STICKY; } Ntf.show(this, true); intentProcessed = true; if (intent != null) { Cfg.Pattern = intent.getIntExtra(TaskerActivity.BUNDLE_PATTERN, Cfg.Pattern); updatePattern(); view.invalidate(); } return START_STICKY; }
@Override public void onDestroy() { super.onDestroy(); destroyed = true; try { android.provider.Settings.System.putInt( getContentResolver(), SAMSUNG_BACK_LIGHT_SETTING, samsungBackLightValue); } catch (Exception e) { } if (lightSensor != null) { unregisterReceiver(screenOffReceiver); sensors.unregisterListener(this, lightSensor); } if (view != null) { windowManager.removeView(view); } Ntf.show(this, false); Log.d(LOG, "Service stopped"); running = false; MainActivity guiCopy = gui; if (guiCopy != null) guiCopy.updateCheckbox(); }