Android Open Source - android-gravity-controls Gravity Controls Broadcast Receiver






From Project

Back to project page android-gravity-controls.

License

The source code is released under:

Copyright (c) 2012 Tristan Waddington <tristan.waddington@gmail.com> Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (...

If you think the Android project android-gravity-controls 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 com.tristanwaddington.gravitycontrols.receiver;
// w  w  w . j  a  va  2 s. co m
import com.tristanwaddington.gravitycontrols.GravityControlsSettingsActivity;
import com.tristanwaddington.gravitycontrols.service.GravityControlsService;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;

public class GravityControlsBroadcastReceiver extends BroadcastReceiver {
    @Override
    public void onReceive(Context context, Intent intent) {
        final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
        final String action = intent.getAction();
        
        if (Intent.ACTION_BOOT_COMPLETED.equals(action)) {
            // Device has finished booting, check to see if we should start
            // up the background service.
            if (preferences.getBoolean(GravityControlsSettingsActivity.START_ON_BOOT_KEY, false)) {
                // Start up the background service
                Intent serviceIntent = new Intent(context, GravityControlsService.class);
                context.startService(serviceIntent);
            }
        }
    }
}




Java Source Code List

com.tristanwaddington.gravitycontrols.GravityControlsLauncherActivity.java
com.tristanwaddington.gravitycontrols.GravityControlsSettingsActivity.java
com.tristanwaddington.gravitycontrols.receiver.GravityControlsBroadcastReceiver.java
com.tristanwaddington.gravitycontrols.service.GravityControlsService.java