How should I implement WakeLock in my above mentioned code?
2011/3/11 Jonathan Foley <jonefo...@gmail.com> > > Is the device going to sleep? If so you'll need to acquire a WakeLock > otherwise it will wake up for the alarm and may fall back asleep > before the notification ever gets fired. > > > Jonathan > > On Mar 10, 10:06 pm, Brad Stintson <geek.bin...@gmail.com> wrote: > > *My application is not triggering notification at specified alarm time. > > Please see below classes and tell me how to do that.* > > * > > * > > * > > * > > *This is my notification class.* > > public class Notificaition extends BroadcastReceiver { > > > > @Override > > public void onReceive(Context context, Intent intent) { > > > > NotificationManager nm = (NotificationManager) context > > .getSystemService(Context.NOTIFICATION_SERVICE); > > CharSequence from = "App Name"; > > CharSequence message = "Event Title"; > > PendingIntent contentIntent = PendingIntent.getActivity(context, 0, > > intent, 0); > > Notification notif = new Notification(R.drawable.icon, > > "EVENT", System.currentTimeMillis()); > > long[] vibrate = {100,100,200,300}; > > notif.vibrate = vibrate; > > notif.defaults =Notification.DEFAULT_ALL; > > notif.setLatestEventInfo(context, from, message, contentIntent); > > nm.notify(1, notif); > > } > > > > *And this is my alarm class* > > public class AlarmTrig extends Activity { > > AlarmManager alarms; > > > > @Override > > public void onCreate(Bundle savedInstanceState) { > > super.onCreate(savedInstanceState); > > setContentView(R.layout.main); > > am = (AlarmManager) getSystemService(Context.ALARM_SERVICE); > > > > setOneTimeAlarm(); > > > > } > > > > public void setOneTimeAlarm() { > > Calendar cal = Calendar.getInstance(); > > > > cal.setTimeInMillis(System.currentTimeMillis()); > > cal.clear(); > > cal.set(Calendar.YEAR, mYear); > > cal.set(Calendar.MONTH,mMonth); > > cal.set(Calendar.DAY_OF_MONTH,mDay); > > cal.set(Calendar.HOUR,mHour); > > cal.set(Calendar.MINUTE,mMinutes); > > cal.set(Calendar.SECOND, mSeconds); > > > > // where mYear, mMonths, mDay, mHour and mMinutes are int values from > the > > Date and Time picker dialogs respectively > > > > Intent activate = new Intent(this, TimeAlarm.class); > > PendingIntent alarmIntent = PendingIntent.getBroadcast(this, 0, > > activate, 0); > > alarms = (AlarmManager)getSystemService(Context.ALARM_SERVICE); > > alarms.set(AlarmManager.RTC_WAKEUP, cal.getTimeInMillis(), > > alarmIntent); > > } > > > > > > > > > > > > > > > > On Thu, Mar 10, 2011 at 7:21 PM, Kostya Vasilyev <kmans...@gmail.com> > wrote: > > > From a database? Same as anything else, by using a query. Probably > easiest > > > to keep date/time values as a long integer (standard Unix > representation). > > > > > Once you have the time value, use AlarmManager and NotificationManager > > > classes in Android. > > > 10.03.2011 16:47 пользователь "Brad Stintson" <geek.bin...@gmail.com> > > > написал: > > > > > > How to get time from database n trigger notification on that time? > > > > > > On Thu, Mar 10, 2011 at 4:45 AM, roberto <roberto.fo...@gmail.com> > > > wrote: > > > > > >> On Mar 9, 11:41 am, Marcin Orlowski <webnet.andr...@gmail.com> > wrote: > > > >> > On 9 March 2011 19:59, roberto <roberto.fo...@gmail.com> wrote: > > > > > >> > >http://hub.buzzbox.com/android-sdk/ > > > > > >> > Looks interesting but I personally am not happy with it being > closed > > > >> > source (which I could stand) but integration with their analics. > Who > > > >> > knows what it analites when your app got internet permission. But > can > > > >> > be I am simply exaggerating :) > > > > > >> the buzzbox sdk actually does not require internet permission if you > > > >> don't want to use the analytics. > > > >> you can use the scheduler without analytics. > > > > > >> Roberto > > > > > >> > -- > > > >> > Regards, > > > >> > Marcin Orlowski > > > > > >> -- > > > >> You received this message because you are subscribed to the Google > > > >> Groups "Android Developers" group. > > > >> To post to this group, send email to > > > android-developers@googlegroups.com > > > >> To unsubscribe from this group, send email to > > > >> android-developers+unsubscr...@googlegroups.com > > > >> For more options, visit this group at > > > >>http://groups.google.com/group/android-developers?hl=en > > > > > > -- > > > > You received this message because you are subscribed to the Google > > > > Groups "Android Developers" group. > > > > To post to this group, send email to > android-developers@googlegroups.com > > > > To unsubscribe from this group, send email to > > > > android-developers+unsubscr...@googlegroups.com > > > > For more options, visit this group at > > > >http://groups.google.com/group/android-developers?hl=en > > > > > -- > > > You received this message because you are subscribed to the Google > > > Groups "Android Developers" group. > > > To post to this group, send email to > android-developers@googlegroups.com > > > To unsubscribe from this group, send email to > > > android-developers+unsubscr...@googlegroups.com > > > For more options, visit this group at > > >http://groups.google.com/group/android-developers?hl=en > > -- > You received this message because you are subscribed to the Google > Groups "Android Developers" group. > To post to this group, send email to android-developers@googlegroups.com > To unsubscribe from this group, send email to > android-developers+unsubscr...@googlegroups.com > For more options, visit this group at > http://groups.google.com/group/android-developers?hl=en > -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en