Establecer notificación a hora específica
Quisiera que mi notificación corra a las 12:00 pm todos los días. ¿Cómo se reemplaza el valor when con un tiempo?
NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); Notification notify = new Notification(R.drawable.icon,"Its Time to Eat",when); Context context = GrubNOWActivity.this; CharSequence title = "Its Time to Eat"; CharSequence details = "Click Here to Search for Restaurants"; Intent intent = new Intent(context,Search.class); PendingIntent pending = PendingIntent.getActivity(context, 0, intent, 0); notify.setLatestEventInfo(context, title, details, pending); nm.notify(0,notify);
- Notificaciones de usuarios - ¿Cómo recuperar un notification_id perdido de GCM?
- ¿Cuál es la diferencia entre v4.app.NotificationCompat y v7.app.NotificationCompat?
- La acción de notificación de Android no se activa (PendingIntent)
- Notificación con sonido aunque el teléfono esté enmudecido
- establecer un temporizador en Android basado en una fecha en la base de datos
- Acción de notificación con intención pendiente que no funciona en JellyBean +
- ¿Cómo borro las notificaciones usando el shell de ADB?
- La notificación de Android no muestra su contenido cuando la aplicación no se está ejecutando
- Notificación personalizada con diseño dinámico en la vista remota
- Cambiar el color del LED para las notificaciones
- Cómo utilizar FLAG_ACTIVITY_SINGLE_TOP y varias tareas con PendingIntents
- ¿Cómo puedo evitar la actualización de notificaciones parpadeantes mientras cambia el botón
- Fragmentos y notificaciones: Objetivo diferentes actividades de notificación; Dependiendo de la configuración de la pantalla
Puede utilizar un administrador de alarmas
Intent myIntent = new Intent(ThisApp.this , myService.class); AlarmManager alarmManager = (AlarmManager)getSystemService(ALARM_SERVICE); pendingIntent = PendingIntent.getService(ThisApp.this, 0, myIntent, 0); Calendar calendar = Calendar.getInstance(); calendar.set(Calendar.HOUR_OF_DAY, 12); calendar.set(Calendar.MINUTE, 00); calendar.set(Calendar.SECOND, 00); alarmManager.setRepeating(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(), 24*60*60*1000 , pendingIntent); //set repeating every 24 hours
Y poner la notificación dentro de la clase myService!
El parámetro when
es para ordenar las notificaciones en la barra de estado. Debe codificar su aplicación de tal manera que active la notificación en el momento deseado.
- Android: Biblioteca de chips para la selección de contactos
- Prueba de unidad de Android para la vista previa de la cámara?