Android Open Source - no-frills-cpu-classic Shutdown Service






From Project

Back to project page no-frills-cpu-classic.

License

The source code is released under:

Apache License

If you think the Android project no-frills-cpu-classic listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package it.sineo.android.noFrillsCPUClassic.service;
/*from   w  ww .  j  a  v a2 s.c  o m*/
import it.sineo.android.noFrillsCPUClassic.extra.Constants;
import android.app.Service;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.IBinder;
import android.preference.PreferenceManager;
import android.util.Log;

public class ShutdownService extends Service {

  @Override
  public IBinder onBind(Intent intent) {
    /*
     * Not working with IPC, we can return null.
     */
    return null;
  }

  @Override
  public void onStart(Intent intent, int startId) {
    super.onCreate();
    Log.d(Constants.APP_TAG, "shutdown service started");
    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
    SharedPreferences.Editor editor = prefs.edit();
    editor.putBoolean(Constants.CHECK_SHUTDOWN_OK, true);
    /*
     * No need to touch LAST_UPDATE, since it'll be checked only if
     * CHECK_SHUTDOWN_OK is false, but we remove the reset point for stats, if
     * it exists.
     */
    if (prefs.contains(Constants.STATS_ZERO_POINT)) {
      editor.remove(Constants.STATS_ZERO_POINT);
    }
    editor.commit();
    stopSelf();
    Log.d(Constants.APP_TAG, "shutdown service stopped");
  }
}




Java Source Code List

it.sineo.android.noFrillsCPUClassic.BootReceiver.java
it.sineo.android.noFrillsCPUClassic.activity.AboutActivity.java
it.sineo.android.noFrillsCPUClassic.activity.MainActivity.java
it.sineo.android.noFrillsCPUClassic.activity.PreferencesActivity.java
it.sineo.android.noFrillsCPUClassic.activity.StatsActivity.java
it.sineo.android.noFrillsCPUClassic.extra.Constants.java
it.sineo.android.noFrillsCPUClassic.extra.Frequency.java
it.sineo.android.noFrillsCPUClassic.extra.PatternReplacerInputFilter.java
it.sineo.android.noFrillsCPUClassic.extra.Stats.java
it.sineo.android.noFrillsCPUClassic.extra.SysUtils.java
it.sineo.android.noFrillsCPUClassic.extra.Theme.java
it.sineo.android.noFrillsCPUClassic.service.BootService.java
it.sineo.android.noFrillsCPUClassic.service.ShutdownService.java
it.sineo.android.noFrillsCPUClassic.widget.StatsWidget.java