Android Open Source - BatteryNotification Preferences Activity






From Project

Back to project page BatteryNotification.

License

The source code is released under:

GNU General Public License

If you think the Android project BatteryNotification 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

/* 
 * Copyright 2014 Julin Zaragoza /*w ww. j a v a  2  s. c om*/
 * 
 * This file is part of BN: Battery Notification
 * 
 * BN: Battery Notification is free software; you can redistribute it and/or modify it under the terms of the GNU 
 * General Public License as published by the Free Software Foundation; either version 2 of the
 * License, or (at your option) any later version. This program is distributed in the hope that it will be
 * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 
 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 
 * You should have received a copy of the GNU General Public License along with this program; if not, 
 * write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 * 
 */
package zarbel.bat.activities;

import zarbel.bat.services.BatteryService;
import zarbel.bat.R;
import android.content.Intent;
import android.os.Bundle;
import android.preference.PreferenceActivity;
/**
 * App Preferences Activity.
 * @author jzaragoza
 *
 */
public class PreferencesActivity extends PreferenceActivity{

  @SuppressWarnings("deprecation")
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    
    //Adding prefereces file to activity
    addPreferencesFromResource(R.xml.defaultprefs);
    
    //Creating battery service
    Intent serviceIntent = new Intent(getApplicationContext(), BatteryService.class);
    startService(serviceIntent);

  }

  @Override
  protected void onStop() {

    //When the activity stops, we recreate the main service with new changes
    //Stop
    stopService(new Intent(PreferencesActivity.this, BatteryService.class));
    
    //Start
    Intent serviceIntent = new Intent(this, BatteryService.class);
    startService(serviceIntent);
    
    super.onStop();
  }


}




Java Source Code List

zarbel.bat.activities.PreferencesActivity.java
zarbel.bat.base.Constants.java
zarbel.bat.broadcastreceivers.Autostart.java
zarbel.bat.services.BatteryService.java
zarbel.bat.services.BatteryThread.java