开发者

Android Notification vibration time

I am using following code for notification. It should vibrate and make sound at the time of event. But it is giving sound when the notification is creating, although the notification time is after 30 min.

final Notification notifyDetails = new Notification(R.drawable.icon, "Myapp",nextAlarmTime);
Context context = getApplicationContext();
CharSequence contentTitle = "Viramune";
CharSequence contentText = notificationAlart;

Intent notifyIntent = new Intent(context, Myapp.class);
PendingIntent intent1 = PendingIntent.getActivity(ViewD开发者_Python百科oughnut.this, 0, notifyIntent, android.content.Intent.FLAG_ACTIVITY_NEW_TASK);
notifyDetails.setLatestEventInfo(context, contentTitle, contentText, intent1);


notifyDetails.flags = Notification.FLAG_ONLY_ALERT_ONCE;
notifyDetails.defaults |= Notification.DEFAULT_SOUND | Notification.DEFAULT_VIBRATE;

mNotificationManager.notify((int) editEventid, notifyDetails);

What is the problem in my code?


Android does exactly what it told to do:

mNotificationManager.notify((int) editEventid, notifyDetails);

This line creates a notification. You should use AlarmManager to schedule your notification in future.


  1. The third parameter to the Notification constructor is not used to determine when to shoot the notification, but is just used for display and sort.
  2. I believe you're trying to do something that needs to be done using AlarmManager, and not Notification.
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜