闹钟AlarmAndMusic 和支持播放音乐效果的,上下滑动调整时间和页面旋转风车效果,
由于制作的gif有些问题,效果不明显,欢迎下载使用看看真实的效果。
本例子主要由AlertActivity和AlarmService和AlarmAlertWakeLock三个类完成。
AlarmAlertWakeLock主要代码如下:
public class AlarmAlertWakeLock {
? ? private static PowerManager.WakeLock sCpuWakeLock;
? ? public static void acquireCpuWakeLock(Context context) {
????? ? Log.v("Acquiring cpu wake lock");
????? ? if (sCpuWakeLock != null) {
????????? ? return;
????? ? }
????? ? PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
????? ? sCpuWakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK
????????????????????????????????????? ? | PowerManager.ACQUIRE_CAUSES_WAKEUP
????????????????????????????????????? ? | PowerManager.ON_AFTER_RELEASE, Log.LOGTAG);
????? ? sCpuWakeLock.acquire();
? ? }
? ? public static void releaseCpuLock() {
????? ? Log.v("Releasing cpu wake lock");
????? ? if (sCpuWakeLock != null) {
????????? ? sCpuWakeLock.release();
????????? ? sCpuWakeLock = null;
????? ? }
? ? }
}
AlarmService主要用来play()音乐。
闹钟AlarmAndMusic 滑动调整时间和页面旋转风车效果
原文:http://chengyi-2015106.iteye.com/blog/2248501