Java Code Examples for android.content.Intent.ACTION_SHUTDOWN

The following are Jave code examples for showing how to use ACTION_SHUTDOWN of the android.content.Intent class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: PrivacyStreams   File: DeviceEventUpdatesProvider.java   View Source Code Vote up 9 votes
@Override
public void onReceive(Context context, Intent intent) {
    String event = null;
    String type = null;

    switch(intent.getAction()){
        case Intent.ACTION_SCREEN_OFF:
            event = DeviceEvent.EVENT_SCREEN_OFF;
            type = DeviceEvent.TYPE_SCREEN;
            break;

        case Intent.ACTION_SCREEN_ON:
            event = DeviceEvent.EVENT_SCREEN_ON;
            type = DeviceEvent.TYPE_SCREEN;
            break;

        case Intent.ACTION_USER_PRESENT:
            event = DeviceEvent.EVENT_SCREEN_USER_PRESENT;
            type = DeviceEvent.TYPE_SCREEN;
            break;

        case Intent.ACTION_BOOT_COMPLETED:
            event = DeviceEvent.EVENT_BOOT_COMPLETED;
            type = DeviceEvent.TYPE_BOOT;
            break;

        case Intent.ACTION_SHUTDOWN:
            event = DeviceEvent.EVENT_BOOT_SHUTDOWN;
            type = DeviceEvent.TYPE_BOOT;
            break;

        case Intent.ACTION_BATTERY_LOW:
            event = DeviceEvent.EVENT_BATTERY_LOW;
            type = DeviceEvent.TYPE_BATTERY;
            break;

        case Intent.ACTION_BATTERY_OKAY:
            event = DeviceEvent.EVENT_BATTERY_OKAY;
            type = DeviceEvent.TYPE_BATTERY;
            break;

        case Intent.ACTION_POWER_CONNECTED:
            event = DeviceEvent.EVENT_BATTERY_AC_CONNECTED;
            type = DeviceEvent.TYPE_BATTERY;
            break;

        case Intent.ACTION_POWER_DISCONNECTED:
            event = DeviceEvent.EVENT_BATTERY_AC_DISCONNECTED;
            type = DeviceEvent.TYPE_BATTERY;
            break;

        case AudioManager.RINGER_MODE_CHANGED_ACTION:
            AudioManager am = (AudioManager)getContext().getSystemService(Context.AUDIO_SERVICE);
            switch (am.getRingerMode()) {
                case AudioManager.RINGER_MODE_SILENT:
                    event = DeviceEvent.EVENT_RINGER_SILENT;
                    type = DeviceEvent.TYPE_RINGER;
                    break;

                case AudioManager.RINGER_MODE_VIBRATE:
                    event = DeviceEvent.EVENT_RINGER_VIBRATE;
                    type = DeviceEvent.TYPE_RINGER;
                    break;

                case AudioManager.RINGER_MODE_NORMAL:
                    event = DeviceEvent.EVENT_RINGER_NORMAL;
                    type = DeviceEvent.TYPE_RINGER;
                    break;
            }
        default:
            break;
    }

    if (type != null)
        output(new DeviceEvent(type, event));
}
 
Example 2
Project: pixelwallpaper   File: PixelWallpaperService.java   View Source Code Vote up 6 votes
public PixelWallpaperEngine() {
	
	prefs = PreferenceManager.getDefaultSharedPreferences(PixelWallpaperService.this);

	Resources res = getResources();

          borderDefault = res.getBoolean(R.bool.pref_border_default);
          blackWhiteDefault = res.getBoolean(R.bool.pref_black_white_default);
	touchmodeDefault = res.getString(R.string.pref_touch_default);
	pixelsizeDefault = res.getString(R.string.pref_pixel_default);
	framerateDefault = res.getString(R.string.pref_frame_default);

          boolean blackWhiteMode = prefs.getBoolean(PreferencesActivity.PREF_BLACK_WHITE, blackWhiteDefault);
	border = prefs.getBoolean(PreferencesActivity.PREF_BORDER, borderDefault);
	touchmode = Integer.valueOf(prefs.getString(PreferencesActivity.PREF_TOUCH, touchmodeDefault));
	pixelsize = Integer.valueOf(prefs.getString(PreferencesActivity.PREF_PIXEL, pixelsizeDefault));
	framerate = Integer.valueOf(prefs.getString(PreferencesActivity.PREF_FRAME, framerateDefault));
	prefs.registerOnSharedPreferenceChangeListener(this);

	IntentFilter filter = new IntentFilter(Intent.ACTION_SHUTDOWN);
	shutdownReceiver = new ShutdownReceiver(this);
	registerReceiver(shutdownReceiver, filter);

	WindowManager wm = (WindowManager) getSystemService(Context.WINDOW_SERVICE);
	Display d = wm.getDefaultDisplay();
	DisplayMetrics dm = new DisplayMetrics();
	d.getMetrics(dm);

	height = dm.heightPixels;
	width = dm.widthPixels;

	pa = new PixelArray(touchmode, blackWhiteMode);

}
 
Example 3
Project: SystemUITuner2   File: ShutDownListen.java   View Source Code Vote up 6 votes
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
    IntentFilter filter = new IntentFilter(Intent.ACTION_SHUTDOWN);
    BroadcastReceiver mReceiver = new ShutDownReceiver();
    registerReceiver(mReceiver, filter);
    return super.onStartCommand(intent, flags, startId);
}
 
Example 4
Project: HeadlineNews   File: IntentUtils.java   View Source Code Vote up 5 votes
/**
 * 获取关机的意图
 * <p>需添加权限 {@code <uses-permission android:name="android.permission.SHUTDOWN"/>}</p>
 *
 * @return intent
 */
public static Intent getShutdownIntent() {
    Intent intent = new Intent(Intent.ACTION_SHUTDOWN);
    return intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
}
 
Example 5
Project: RLibrary   File: IntentUtils.java   View Source Code Vote up 4 votes
/**
 * 获取关机的意图
 * <p>需添加权限 {@code <uses-permission android:name="android.permission.SHUTDOWN"/>}</p>
 *
 * @return intent
 */
public static Intent getShutdownIntent() {
    Intent intent = new Intent(Intent.ACTION_SHUTDOWN);
    return intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
}
 
Example 6
Project: GitHub   File: IntentUtils.java   View Source Code Vote up 3 votes
/**
 * 获取关机的意图
 * <p>需添加权限 {@code <uses-permission android:name="android.permission.SHUTDOWN"/>}</p>
 *
 * @return intent
 */
public static Intent getShutdownIntent() {
    Intent intent = new Intent(Intent.ACTION_SHUTDOWN);
    return intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
}
 
Example 7
Project: codedemos   File: IntentUtil.java   View Source Code Vote up 3 votes
/**
 * 获取关机的意图
 * <p>需添加权限 {@code <uses-permission android:name="android.permission.SHUTDOWN"/>}</p>
 *
 * @return intent
 */
public static Intent getShutdownIntent() {
    Intent intent = new Intent(Intent.ACTION_SHUTDOWN);
    return intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
}
 
Example 8
Project: Android-UtilCode   File: IntentUtils.java   View Source Code Vote up 3 votes
/**
 * 获取关机的意图
 * <p>需添加权限 {@code <uses-permission android:name="android.permission.SHUTDOWN"/>}</p>
 *
 * @return intent
 */
public static Intent getShutdownIntent() {
    Intent intent = new Intent(Intent.ACTION_SHUTDOWN);
    return intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
}
 
Example 9
Project: AndroidUtilCode-master   File: IntentUtils.java   View Source Code Vote up 3 votes
/**
 * 获取关机的意图
 * <p>需添加权限 {@code <uses-permission android:name="android.permission.SHUTDOWN"/>}</p>
 *
 * @return intent
 */
public static Intent getShutdownIntent() {
    Intent intent = new Intent(Intent.ACTION_SHUTDOWN);
    return intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
}
 
Example 10
Project: LJFramework   File: IntentUtils.java   View Source Code Vote up 3 votes
/**
 * 获取关机的意图
 * <p>需添加权限 {@code <uses-permission android:name="android.permission.SHUTDOWN"/>}</p>
 *
 * @return intent
 */
public static Intent getShutdownIntent() {
    Intent intent = new Intent(Intent.ACTION_SHUTDOWN);
    return intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
}
 
Example 11
Project: Coder   File: IntentUtils.java   View Source Code Vote up 3 votes
/**
 * 获取关机的意图
 * <p>需添加权限 {@code <uses-permission android:name="android.permission.SHUTDOWN"/>}</p>
 *
 * @return intent
 */
public static Intent getShutdownIntent() {
    Intent intent = new Intent(Intent.ACTION_SHUTDOWN);
    return intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
}
 
Example 12
Project: EasyAndroid   File: IntentTool.java   View Source Code Vote up 3 votes
/**
 * 获取关机的意图
 * <p>需添加权限 {@code <uses-permission android:name="android.permission.SHUTDOWN"/>}</p>
 *
 * @return intent
 */
public static Intent getShutdownIntent()
{
    Intent intent = new Intent(Intent.ACTION_SHUTDOWN);
    return intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
}
 
Example 13
Project: BaseCore   File: IntentUtils.java   View Source Code Vote up 3 votes
/**
 * 获取关机的意图
 * <p>需添加权限 {@code <uses-permission android:name="android.permission.SHUTDOWN"/>}</p>
 *
 * @return intent
 */
public static Intent getShutdownIntent() {
    Intent intent = new Intent(Intent.ACTION_SHUTDOWN);
    return intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
}