# 定时开关机设置 **Repository Path**: cmlsky/dingshikaiguanjishezhi ## Basic Information - **Project Name**: 定时开关机设置 - **Description**: No description available - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 2 - **Created**: 2022-03-26 - **Last Updated**: 2022-03-26 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # 定时开关机设置 #### 介绍 MTK android 定时快关机设置api示例 #### 使用说明 核心类 Alarms.java 核心函数 1 设置定时开关机 ``` /** * A convenience method to set an alarm in the Alarms content provider. * @param context Context * @param id corresponds to the _id column * @param enabled corresponds to the ENABLED column * @param hour corresponds to the HOUR column * @param minutes corresponds to the MINUTES column * @param daysOfWeek corresponds to the DAYS_OF_WEEK column * @param vibrate corresponds to the VIBRATE column * @param message corresponds to the MESSAGE column * @param alert corresponds to the ALERT column */ ** public static void setAlarm(Context context, int id, boolean enabled, int hour, int minutes, Alarm.DaysOfWeek daysOfWeek, boolean vibrate, String message, String alert);** ``` id: 有四个值分别是1,2,3,4;分别对应:定时开机1,定时关机1,定时开机2,定时关机2; enabled: 是否开机定时开/关机 hour: 时 minutes: 分 daysOfWeek 设置星期某天重复,比如周一是new Alarm.DaysOfWeek(1) 周二new Alarm.DaysOfWeek(2) 周一至周五new Alarm.DaysOfWeek(31) 周一至周日new Alarm.DaysOfWeek(127) 周六周末new Alarm.DaysOfWeek(96) vibrate:是否震动 2. 开启或关闭定时开关机 ``` /** * A convenience method to enable or disable an alarm. * @param context Context **粗体** * @param id corresponds to the _id column * @param enabled corresponds to the ENABLED column */ ** public static void enableAlarm(final Context context, final int id, boolean enabled) ;** ``` id: 有四个值分别是1,2,3,4;分别对应:定时开机1,定时关机1,定时开机2,定时关机2; enabled: 是否开机定时开/关机 集成到别的代码,要注意AndroidManifest.xml权限 ` `