开发者

how to set alarm for my Database Values?

开发者 https://www.devze.com 2023-04-05 00:02 出处:网络
I am trying to set alarm for my database values. In database i am saving 4 values alarm1, alarm2, alarm3, alarm4 in a sin开发者_Go百科gle row. I need to set alarm for those 4 values. How can i set ala

I am trying to set alarm for my database values. In database i am saving 4 values alarm1, alarm2, alarm3, alarm4 in a sin开发者_Go百科gle row. I need to set alarm for those 4 values. How can i set alarm for my application. Please any one help me. Below is the code for setting alarm.

Intent myIntent = new Intent(this, MyAlarmService.class); 
    pendingIntent = PendingIntent.getService(this, (int) System.currentTimeMillis(), myIntent, 0); 

    AlarmManager alarmManager = (AlarmManager)getSystemService(ALARM_SERVICE);

    Calendar calendar = Calendar.getInstance();
    calendar.set(Calendar.HOUR_OF_DAY, hour1);
    calendar.set(Calendar.MINUTE, min1);  
    calendar.set(Calendar.SECOND, 0);    

    alarmManager.setRepeating(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(), 24*60*60*1000, pendingIntent);

    Toast.makeText(this, "Start Daily Alarm", Toast.LENGTH_LONG).show();  


How are you saving the alarms in DB if you are saving in DB as Strings you need to retrieve those values and need to convert those values to date formats and then you have to use push notifications similar in iphone

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号