當前位置: 首頁>>代碼示例>>Java>>正文


Java Intent.ACTION_SHUTDOWN屬性代碼示例

本文整理匯總了Java中android.content.Intent.ACTION_SHUTDOWN屬性的典型用法代碼示例。如果您正苦於以下問題:Java Intent.ACTION_SHUTDOWN屬性的具體用法?Java Intent.ACTION_SHUTDOWN怎麽用?Java Intent.ACTION_SHUTDOWN使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在android.content.Intent的用法示例。


在下文中一共展示了Intent.ACTION_SHUTDOWN屬性的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: onReceive

@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));
}
 
開發者ID:PrivacyStreams,項目名稱:PrivacyStreams,代碼行數:76,代碼來源:DeviceEventUpdatesProvider.java

示例2: PixelWallpaperEngine

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);

}
 
開發者ID:connyduck,項目名稱:pixelwallpaper,代碼行數:34,代碼來源:PixelWallpaperService.java

示例3: onStartCommand

@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);
}
 
開發者ID:zacharee,項目名稱:SystemUITuner2,代碼行數:7,代碼來源:ShutDownListen.java

示例4: getShutdownIntent

/**
 * 獲取關機的意圖
 * <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);
}
 
開發者ID:Wilshion,項目名稱:HeadlineNews,代碼行數:10,代碼來源:IntentUtils.java

示例5: getShutdownIntent

/**
 * 獲取關機的意圖
 * <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);
}
 
開發者ID:Ayvytr,項目名稱:EasyAndroid,代碼行數:11,代碼來源:IntentTool.java


注:本文中的android.content.Intent.ACTION_SHUTDOWN屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。