package android.app; import android.os.RemoteException; import android.os.ServiceManager; import android.util.Log; /** * This class provides access to the system uimode services. These services * allow applications to control UI modes of the device. * It provides functionality to disable the car mode and it gives access to the * night mode settings. * *
You do not instantiate this class directly; instead, retrieve it through * {@link android.content.Context#getSystemService * Context.getSystemService(Context.UI_MODE_SERVICE)}. */ public class UiModeManager { private static final String TAG = "UiModeManager"; public static final int MODE_NOTNIGHT = 1; public static final int MODE_NIGHT = 2; public static final int MODE_AUTO = 3; private IUiModeManager mService; /*package*/ UiModeManager() { mService = IUiModeManager.Stub.asInterface( ServiceManager.getService("uimode")); } /** * Disables the car mode. */ public void disableCarMode() { if (mService != null) { try { mService.disableCarMode(); } catch (RemoteException e) { Log.e(TAG, "disableCarMode: RemoteException", e); } } } /** * Sets the night mode. Changes to the night mode are only effective when * the car mode is enabled on a device. * *
The mode can be one of: *