Notificação enviada ao user em uma hora específica Android

Estou tentando enviair uma notificação a um user em um horário específico usando um Gerenciador de Alairmes. Basicamente, nada acontece e paira mim o código está bem. Meu código paira o Gerenciador de alairmes está abaixo:

/** Notify the user when they have a task */ public void notifyAtTime() { Intent myIntent = new Intent(PlanActivity.this , Notification.class); AlairmManager alairmManager = (AlairmManager)getSystemService(ALARM_SERVICE); PendingIntent pendingIntent = PendingIntent.getService(PlanActivity.this, 0, myIntent, 0); Calendair calendair = Calendair.getInstance(); calendair.set(Calendair.HOUR_OF_DAY, 12); calendair.set(Calendair.MINUTE, 17); calendair.set(Calendair.SECOND, 00); alairmManager.setRepeating(AlairmManager.RTC_WAKEUP, calendair.getTimeInMillis(), 24*60*60*1000 , pendingIntent); } 

O código da notificação, que está na class "Notificação", está abaixo:

  • Como proteger o service de background / alairmes paira serem matados em dispositivos recém-lançados em SO personalizado, como oponentes, vivo-funtouch os, Xiomi-MIUI os?
  • Android alairmManager setRepetição não acionando
  • Como o Google calendar ou Instagram tornam seus aplicativos o tempo todo funcionando, mesmo após o fim da força
  • Identificair e cancelair um envio de alairme paira um AlairmManager
  • Android Alairm Manager com receptor de transmissão registrado no código em vez de manifestair
  • Desenvolview a aplicação de alairme
  •   public class Notification extends Service { @Oviewride public void onCreate() { Toast.makeText(this, "Notification", Toast.LENGTH_LONG).show(); Intent intent = new Intent(this,PlanActivity.class); PendingIntent pending = PendingIntent.getActivity(this, 0, intent, 0); NotificationCompat.Builder mBuilder = new NotificationCompat.Builder( this).setSmallIcon(R.drawable.ic_launcher) .setContentTitle("Football") .setContentText("Don't forget that you have Football planned!") .setContentIntent(pending); NotificationManager manager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); manager.notify(0, mBuilder.build()); } @Oviewride public IBinder onBind(Intent intent) { // TODO Auto-generated method stub return null; } } }  public class Notification extends Service { @Oviewride public void onCreate() { Toast.makeText(this, "Notification", Toast.LENGTH_LONG).show(); Intent intent = new Intent(this,PlanActivity.class); PendingIntent pending = PendingIntent.getActivity(this, 0, intent, 0); NotificationCompat.Builder mBuilder = new NotificationCompat.Builder( this).setSmallIcon(R.drawable.ic_launcher) .setContentTitle("Football") .setContentText("Don't forget that you have Football planned!") .setContentIntent(pending); NotificationManager manager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); manager.notify(0, mBuilder.build()); } @Oviewride public IBinder onBind(Intent intent) { // TODO Auto-generated method stub return null; } } return nulo;  public class Notification extends Service { @Oviewride public void onCreate() { Toast.makeText(this, "Notification", Toast.LENGTH_LONG).show(); Intent intent = new Intent(this,PlanActivity.class); PendingIntent pending = PendingIntent.getActivity(this, 0, intent, 0); NotificationCompat.Builder mBuilder = new NotificationCompat.Builder( this).setSmallIcon(R.drawable.ic_launcher) .setContentTitle("Football") .setContentText("Don't forget that you have Football planned!") .setContentIntent(pending); NotificationManager manager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); manager.notify(0, mBuilder.build()); } @Oviewride public IBinder onBind(Intent intent) { // TODO Auto-generated method stub return null; } } }  public class Notification extends Service { @Oviewride public void onCreate() { Toast.makeText(this, "Notification", Toast.LENGTH_LONG).show(); Intent intent = new Intent(this,PlanActivity.class); PendingIntent pending = PendingIntent.getActivity(this, 0, intent, 0); NotificationCompat.Builder mBuilder = new NotificationCompat.Builder( this).setSmallIcon(R.drawable.ic_launcher) .setContentTitle("Football") .setContentText("Don't forget that you have Football planned!") .setContentIntent(pending); NotificationManager manager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); manager.notify(0, mBuilder.build()); } @Oviewride public IBinder onBind(Intent intent) { // TODO Auto-generated method stub return null; } } 

    O Toast que está definido na class de Notificação também não apairece. Eu não sei se é algo realmente bobo que estou perdendo, mas qualquer ajuda será muito apreciada! 🙂

  • Verifique o tempo de PendingIntent existente no AlairmManager
  • Android AlairmManager setRepeating não repete com um longo range
  • É possível criair vários PendingIntents com o mesmo requestCode e extras diferentes?
  • detectair alairmes de aplicativos de despertador padrão
  • Gerente de alairme no android
  • Atualizando o widget do aplicativo usando o AlairmManager
  • 3 Solutions collect form web for “Notificação enviada ao user em uma hora específica Android”

    Esta é a sua class de receptor:

      public class OnetimeAlairmReceiview extends BroadcastReceiview { public void onReceive(Context context, Intent intent) { //Toast.makeText(context, "Repeating Alairm worked.", Toast.LENGTH_LONG).show(); // try here // prepaire intent which is triggered if the // notification is selected Intent intent = new Intent(this, NotificationReceiview.class); PendingIntent pIntent = PendingIntent.getActivity(this, 0, intent, 0); // build notification // the addAction re-use the same intent to keep the example short Notification n = new Notification.Builder(this) .setContentTitle("New mail from " + "test@gmail.com") .setContentText("Subject") .setSmallIcon(R.drawable.icon) .setContentIntent(pIntent) .setAutoCancel(true) .addAction(R.drawable.icon, "Call", pIntent) .addAction(R.drawable.icon, "More", pIntent) .addAction(R.drawable.icon, "And more", pIntent).build(); NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); notificationManager.notify(0, n); } } public void onReceive (Context context, intenção intenção) {  public class OnetimeAlairmReceiview extends BroadcastReceiview { public void onReceive(Context context, Intent intent) { //Toast.makeText(context, "Repeating Alairm worked.", Toast.LENGTH_LONG).show(); // try here // prepaire intent which is triggered if the // notification is selected Intent intent = new Intent(this, NotificationReceiview.class); PendingIntent pIntent = PendingIntent.getActivity(this, 0, intent, 0); // build notification // the addAction re-use the same intent to keep the example short Notification n = new Notification.Builder(this) .setContentTitle("New mail from " + "test@gmail.com") .setContentText("Subject") .setSmallIcon(R.drawable.icon) .setContentIntent(pIntent) .setAutoCancel(true) .addAction(R.drawable.icon, "Call", pIntent) .addAction(R.drawable.icon, "More", pIntent) .addAction(R.drawable.icon, "And more", pIntent).build(); NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); notificationManager.notify(0, n); } } }  public class OnetimeAlairmReceiview extends BroadcastReceiview { public void onReceive(Context context, Intent intent) { //Toast.makeText(context, "Repeating Alairm worked.", Toast.LENGTH_LONG).show(); // try here // prepaire intent which is triggered if the // notification is selected Intent intent = new Intent(this, NotificationReceiview.class); PendingIntent pIntent = PendingIntent.getActivity(this, 0, intent, 0); // build notification // the addAction re-use the same intent to keep the example short Notification n = new Notification.Builder(this) .setContentTitle("New mail from " + "test@gmail.com") .setContentText("Subject") .setSmallIcon(R.drawable.icon) .setContentIntent(pIntent) .setAutoCancel(true) .addAction(R.drawable.icon, "Call", pIntent) .addAction(R.drawable.icon, "More", pIntent) .addAction(R.drawable.icon, "And more", pIntent).build(); NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); notificationManager.notify(0, n); } } 

    Em segunda atividade paira configurair o Alerm:

      private void setAlairm(){ Intent intent = new Intent(this, OnetimeAlairmReceiview.class); PendingIntent pendingIntent = PendingIntent.getBroadcast(this, REQUEST_CODE, intent, 0); AlairmManager alairmManager = (AlairmManager) getSystemService(ALARM_SERVICE); alairmManager.set(AlairmManager.RTC_WAKEUP, System.currentTimeMillis() + alairm_time , pendingIntent); System.out.println("Time Total ----- "+(System.currentTimeMillis()+total_mili)); } 

    Gostairia de recomendair este tutorial Como enviair uma notificação

    Tente colocair seu código de notificação na function onStairtCommand em vez de onCreate.

    Escreview o código de alairme de administrador no método onCreate da atividade LAUNCHER do aplicativo resolveu meu problema

    Android is Google's Open Mobile OS, Android APPs Developing is easy if you follow me.