android - How to check date from sqlite database? -
i have sqlite database table contacts friend , contacts date of birth.i want ring alarm when date match database current date.please me how task. want match date 2 time day daily please suggest me.
i using code
private void setalarm(string name,string date) { string[] arrdob =date.split("/"); calendar cal = calendar.getinstance(); //for using need import java.util.calendar; // add minutes calendar object cal.set(calendar.month,integer.parseint(arrdob[1])); cal.set(calendar.year, integer.parseint(arrdob[2])); cal.set(calendar.day_of_month,integer.parseint(arrdob[0])); cal.set(calendar.hour_of_day,14); cal.set(calendar.minute,35); system.out.println("1"); intent alarmintent = new intent(getapplicationcontext(), alarmreceiver.class); alarmintent.putextra("title","b'day alarm"); alarmintent.putextra("subject","hi!todays "+name+" b'day"); pendingintent sender = pendingintent.getbroadcast(getapplicationcontext(), hello_id, alarmintent,pendingintent.flag_update_current | intent.fill_in_data); //very important set flag_update_current... send correct extra's informations //alarmreceiver class // alarmmanager service alarmmanager = (alarmmanager) getsystemservice(alarm_service); am.set(alarmmanager.rtc_wakeup, cal.gettimeinmillis(), sender); } call method @ when insert value database. alarmreceiver class as:
private static int notification_id = 1; @override public void onreceive(context context, intent intent) // { // notificationmanager mnotificationmanager = system.out.println("2"); //context.getsystemservice(context.notification_service); notificationmanager manger = (notificationmanager) context.getsystemservice(context.notification_service); notification notification = new notification(r.drawable.ic_launcher, "combi note",system.currenttimemillis()); pendingintent contentintent = pendingintent.getactivity(context, notification_id, new intent(context, alarmreceiver.class), 0); bundle extras=intent.getextras(); string title=extras.getstring("title"); //here title , description of our notification string note=extras.getstring("subject"); notification.setlatesteventinfo(context, note, title, contentintent); notification.flags = notification.flag_insistent; notification.defaults |= notification.default_sound; //here set default sound our //notification
// pendingintent launch our activity if user selects notification manger.notify(notification_id++, notification); }
Comments
Post a Comment