2013-08-02 6 views
0

Я хочу добавить Notificationmanager, который должен начинаться через несколько миллисекунд. Все работает, но все же я не знаю, как добавить время уведомления, например, через несколько недель?Уведомление через некоторое время

public void test(){ 
    int icon = R.drawable.ic_launcher; 
    CharSequence ticker ="ticker"; 
    long showAt =System.currentTimeMillis(); 
    Notification notification = new Notification(icon, ticker, showAt);activity/intent 
    CharSequence notificationTitle = "test"; 
    CharSequence notificationMessage = "Test1"; 
    Intent intent = new Intent(this, Activity.class); 
    PendingIntent objPendingIntent = PendingIntent.getActivity(this, 0, intent, 0); 
    Context ctx = getApplicationContext(); 
    notification.setLatestEventInfo(ctx, notificationTitle, notificationMessage, objPendingIntent); 
    final int notificationIdentifier = 101; //an unique number set by developer to identify a notification, using this notification can be updated/replaced 
    NotificationManager notificationManager = (NotificationManager) 
      getSystemService(Context.NOTIFICATION_SERVICE); 
    notificationManager.notify(notificationIdentifier, notification); 
    // ... 
} 

ответ

1

Вы должны использовать Alarm manager с уведомлением для повторения вашего уведомления после очередного интервала времени. Проверьте AlarmManagerNotificationManagerTutorial, Android AlarmManager tutorial и Multiple Notifications Using AlarmManager. Там много учебных пособий. Надеюсь это поможет.

+0

как я могу сделать только одно уведомление, не повторяя ?? Теперь он повторяет уведомление каждые 6 секунд –

+0

Вы хотели, чтобы он повторялся каждую неделю? Покажите свой код .. –

Смежные вопросы