Moreover, if i set reminder to current time using
alarms.setRepeating(AlarmManager.ELAPSED_REALTIME,
SystemClock.elapsedRealtime(),
30 * 1000, alarmIntent);
then it is notifying perfectly.
2011/3/11 Brad Stintson <[email protected]>
>
>
> 2011/3/11 Kostya Vasilyev <[email protected]>
>
> Before you look into using a WakeLock (which might not be necessary, since
>> Android keeps a wake lock for the duration of your onReceive)...
>>
>> There are a few things in your code that look rather strange to me:
>>
>> 1 - Your broadcast receiver is called Notification (bad name, btw, as it
>> clashes with an Android class), and yet when setting the alarm, you use
>> TimeAlarm:
>>
>>
>> Intent activate = new Intent(this, *TimeAlarm*.class);
>>
>
> I changed this to notification class
>
>>
>> 2 - Inside onReceive, you call PendingIntent.getActivity() with the intent
>> received by the broadcast receiver. Does that intent really point to an
>> Activity?
>>
>
> I removed that
>
>>
>> 3 - Not shown in your original email, but - did you declare your broadcast
>> receiver in the manifest?
>>
>
> Ya I have declared that
>
> But still it is not showing on specified time.
>
>>
>> After dealing with the above, as next step, I'd add debug logging, shorten
>> the alarm interval just for debugging (say, five minutes) and check what
>> happens.
>>
>> -- Kostya
>>
>> 11.03.2011 19:22, Brad Stintson пишет:
>>
>> How should I implement WakeLock in my above mentioned code?
>>
>>
>> 2011/3/11 Jonathan Foley <[email protected]>
>>
>>>
>>> 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 <[email protected]> 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 <[email protected]>
>>> 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" <
>>> [email protected]>
>>> > > написал:
>>> >
>>> > > > How to get time from database n trigger notification on that time?
>>> >
>>> > > > On Thu, Mar 10, 2011 at 4:45 AM, roberto <[email protected]
>>> >
>>> > > wrote:
>>> >
>>> > > >> On Mar 9, 11:41 am, Marcin Orlowski <[email protected]>
>>> wrote:
>>> > > >> > On 9 March 2011 19:59, roberto <[email protected]> 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
>>> > > [email protected]
>>> > > >> To unsubscribe from this group, send email to
>>> > > >> [email protected]
>>> > > >> 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
>>> [email protected]
>>> > > > To unsubscribe from this group, send email to
>>> > > > [email protected]
>>> > > > 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
>>> [email protected]
>>> > > To unsubscribe from this group, send email to
>>> > > [email protected]
>>> > > 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 [email protected]
>>> To unsubscribe from this group, send email to
>>> [email protected]
>>> 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 [email protected]
>> To unsubscribe from this group, send email to
>> [email protected]
>> For more options, visit this group at
>> http://groups.google.com/group/android-developers?hl=en
>>
>>
>>
>> --
>> Kostya Vasilyev -- http://kmansoft.wordpress.com
>>
>> --
>> You received this message because you are subscribed to the Google
>> Groups "Android Developers" group.
>> To post to this group, send email to [email protected]
>> To unsubscribe from this group, send email to
>> [email protected]
>> 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 [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en