I'd like to start my AlarmManager activity at a time specified by the user however the time string is stored in standard format (ex - 7:30) how can I use the AlarmManager to interact with a long value which is stored in standard format - instead of miliseconds as it usually is? Is it possible to do this without converting it into miliseconds? If so - how? If not - what is the 2nd best alternative? (I simply need to know the easiest way to wake an alarm if my time string is in standard format.)
SOURCE:
String time = 7:30
Intent intent2 = new Intent(New.this, Start.class);
PendingIntent pintent2 = PendingIntent.getActivity(Rules.this, 0, intent2,
0);
AlarmManager alarm2 = (AlarmManager) getSystemService(Context.ALARM_SERVICE);
alarm2.setRepeating(AlarmManager.RTC_WAKEUP, cal.getTimeInMillis(),
time != null ? 1000 : 0, pintent2);
EDIT:
I'm attempting to use the following method I found: Date d = DateFormat.parse(time); long millisec = d.getTime(); but I'm getting an error stating "The method parse(String) is undefined for the type DateFormat" - any ideas why?
.
stackoverflow.comm
No comments:
Post a Comment