鬧鐘鬧不醒的可以自己去調(diào)整下,這個(gè)最是最基本的
站在用戶的角度思考問題,與客戶深入溝通,找到遂川網(wǎng)站設(shè)計(jì)與遂川網(wǎng)站推廣的解決方案,憑借多年的經(jīng)驗(yàn),讓設(shè)計(jì)與互聯(lián)網(wǎng)技術(shù)結(jié)合,創(chuàng)造個(gè)性化、用戶體驗(yàn)好的作品,建站類型包括:成都網(wǎng)站設(shè)計(jì)、做網(wǎng)站、企業(yè)官網(wǎng)、英文網(wǎng)站、手機(jī)端網(wǎng)站、網(wǎng)站推廣、域名申請(qǐng)、虛擬主機(jī)、企業(yè)郵箱。業(yè)務(wù)覆蓋遂川地區(qū)。MainActivity
public class MainActivity extends AppCompatActivity { private AlarmManager alarmManager; private PendingIntent pendingIntent; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); //獲取鬧鐘管理者 alarmManager = (AlarmManager) getSystemService(Context.ALARM_SERVICE); } public void setAlarmOne(View view) { //獲取當(dāng)前系統(tǒng)時(shí)間 Calendar calendar = Calendar.getInstance(); int huor = calendar.get(Calendar.HOUR_OF_DAY); int minute = calendar.get(Calendar.MINUTE); //1 彈出時(shí)間對(duì)話框 TimePickerDialog timePickerDialog = new TimePickerDialog(this, new TimePickerDialog.OnTimeSetListener() { @Override public void onTimeSet(TimePicker view, int i, int i1) { Calendar c = Calendar.getInstance(); c.set(Calendar.HOUR_OF_DAY, i); c.set(Calendar.MINUTE, i1); //2確定好選擇的時(shí)間 //3設(shè)置鬧鐘 //4當(dāng)時(shí)間一到,將執(zhí)行的響應(yīng) Intent intent=new Intent(); intent.setAction("com.zking.risk_android_alarn_notification.RING"); pendingIntent = PendingIntent.getBroadcast(MainActivity.this,0x101,intent,0); alarmManager.set(AlarmManager.RTC_WAKEUP,c.getTimeInMillis(), pendingIntent); } }, huor, minute, true); timePickerDialog.show(); } public void setAlarmCycle(View view) { //獲取當(dāng)前系統(tǒng)時(shí)間 Calendar calendar=Calendar.getInstance(); int hour=calendar.get(Calendar.HOUR_OF_DAY); int minute=calendar.get(Calendar.MINUTE); //01.彈出時(shí)間對(duì)話框 TimePickerDialog timePickerDialog=new TimePickerDialog(this, new TimePickerDialog.OnTimeSetListener() { @Override public void onTimeSet(TimePicker timePicker, int i, int i1) { Calendar c=Calendar.getInstance(); c.set(Calendar.HOUR_OF_DAY,i); c.set(Calendar.MINUTE,i1); //02.確定好選擇的時(shí)間 //03.設(shè)置鬧鐘 //04.當(dāng)之間一到,將執(zhí)行的響應(yīng) Intent intent=new Intent(); intent.setAction("com.zking.risk_android_alarn_notification.RING"); pendingIntent = PendingIntent.getBroadcast(MainActivity.this,0x102,intent,0); alarmManager.setRepeating(AlarmManager.RTC_WAKEUP,c.getTimeInMillis(),5000, pendingIntent); } },hour,minute,true); timePickerDialog.show(); } public void cancelAlarmCycle(View view){ alarmManager.cancel(pendingIntent); } }
文章名稱:Android實(shí)現(xiàn)鬧鐘功能小Dome-創(chuàng)新互聯(lián)
網(wǎng)頁地址:http://aaarwkj.com/article36/gpdsg.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供微信公眾號(hào)、虛擬主機(jī)、定制開發(fā)、網(wǎng)站內(nèi)鏈、網(wǎng)站建設(shè)、搜索引擎優(yōu)化
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內(nèi)容