Recordatorio de Android

Me gustaría preguntar qué servicio y cómo utilizar para hacer recordatorio en android … Digamos: después de 10 minutos a partir de ahora me muestran notificación en la barra de notificación …

Gracias por tu respuesta

Obviamente debe usar AlarmManager para configurar algo que se ejecutará en PERIODO dado.

AlarmManager mgr = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE); Intent i = new Intent(context, OnAlarmReceiver.class); PendingIntent pi = PendingIntent.getBroadcast(context, 0, i, 0); mgr.setRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP, SystemClock.elapsedRealtime(), PERIOD, pi); 

donde el PERIOD es su tiempo para algo que debe ser ejecutado en OnAlarmReceiver. Y entonces, simplemente implemente el método en

 @Override public void onReceive(Context context, Intent intent) { NotificationManager nm = (NotificationManager); context.getSystemService(Context.NOTIFICATION_SERVICE); Notification notification = new Notification(); notification.tickerText = "10 Minutes past"; nm.notify(0, notification); } 

Disfrutar.

Debería utilizar AlarmManager . Con él puede programar una intención para ser entregado. Crear un BroadcastReceiver para obtenerlo y mostrar la notificación.

Somethink como esto supongo, usted comienza un runnable después de 10min y abre una notificación en el código del runnable.

 Runnable reminder = new Runnable() { public void run() { int NOTIFICATION_ID = 1324; NotificationManager notifManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); Notification note = new Notification(R.drawable.icon, "message", System.currentTimeMillis()); // Add and AUTO_CANCEL flag to the notification, // this automatically removes the notification when the user presses it note.flags |= Notification.FLAG_AUTO_CANCEL; PendingIntent i = PendingIntent.getActivity(this, 0, new Intent(this, ActivityToOpen.class), 0); note.setLatestEventInfo(this, "message", title, i); notifManager.notify(NOTIFICATION_ID, note); } }; Handler handler = new Handler(); handler.postDelayed(reminder, 600000); 
  • El texto de notificación es demasiado largo y no muestra el texto completo.
  • Notificación en tiempo específico
  • PendingIntent error (Debe haber uno o más de: PendingIntent.FLAG_ONE_SHOT ... ..)
  • ¿Cómo puedo activar las vibraciones y las luces con la API de notificaciones de Android?
  • Atrapar en el golpe para despedir el evento
  • ¿Cuál es la diferencia entre: notification.flags y notification.defaults?
  • Notificación no mostrada cuando setGroup () se llama en Android KitKat
  • ¿Son confiables las notificaciones push de Android?
  • Recibe notificación push de Android aunque la aplicación esté cerrada
  • Cerrar Notificación de Android
  • El comportamiento anormal de la aplicación no inicia la actividad mencionada en la intención
  • FlipAndroid es un fan de Google para Android, Todo sobre Android Phones, Android Wear, Android Dev y Aplicaciones para Android Aplicaciones.