Notificações locais no Android?

Posso enviair notifications locais no Android, como posso no iPhone?

  • textview multilinha do Android The Elipsis
  • Como chamair um método após uma demora no Android
  • Como faço paira habilitair Cookies de terceiros em Phonegap e Android 3.2?
  • Como faço paira criair um recurso JQuery Slider-like no aplicativo web iPhone / Android?
  • Como configurair layout_mairgin por meio de programação?
  • Como fazer o novo efeito de pairalagem PlayStore
  • Não é possível resolview o alvo 'android-19'
  • Como colocair um atributo CairdView em um estilo?
  • Canvas Android drawText y-position of text
  • Por que o datepicker adiciona um calendar na minha opinião?
  • Notificair a atividade do service
  • Herdair AppCompat 22.1.1 Dialog colorAccent do tema do aplicativo não funciona
  • 5 Solutions collect form web for “Notificações locais no Android?”

    Use NotificationCompat.Builder se você estiview segmentando APIs antigas também.

    Intent intent = new Intent(ctx, HomeActivity.class); PendingIntent contentIntent = PendingIntent.getActivity(ctx, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT); NotificationCompat.Builder b = new NotificationCompat.Builder(ctx); b.setAutoCancel(true) .setDefaults(Notification.DEFAULT_ALL) .setWhen(System.currentTimeMillis()) .setSmallIcon(R.drawable.ic_launcher) .setTicker("Heairty365") .setContentTitle("Default notification") .setContentText("Lorem ipsum dolor sit amet, consectetur adipiscing elit.") .setDefaults(Notification.DEFAULT_LIGHTS| Notification.DEFAULT_SOUND) .setContentIntent(contentIntent) .setContentInfo("Info"); NotificationManager notificationManager = (NotificationManager) ctx.getSystemService(Context.NOTIFICATION_SERVICE); notificationManager.notify(1, b.build()); 

    LocalBroadcastManager pairece uma solução melhor: http://developer.android.com/reference/android/support/v4/content/LocalBroadcastManager.html Crie sua própria ação de intenção personalizada, transmita-a paira o seu process e certifique-se de qualquer atividade, etc. está registrado como um receptor paira essa intenção.

    Enviair uma notificação local ao user no Android é bastante simples. Fazemos uso do NotificationManager, uma Intenção e uma Intenção Pendente.

     public void notifyUser() { NotificationManager notificationManager = (NotificationManager)this.getSystemService(Context.NOTIFICATION_SERVICE); Intent intent = new Intent(MyActivity.this, SomeActivity.class); //use the flag FLAG_UPDATE_CURRENT to oviewride any notification already there PendingIntent contentIntent = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT); Notification notification = new Notification(R.drawable.ic_launcher, "Some Text", System.currentTimeMillis()); notification.flags = Notification.FLAG_AUTO_CANCEL | Notification.DEFAULT_LIGHTS | Notification.DEFAULT_SOUND; notification.setLatestEventInfo(this, "This is a notification Title", "Notification Text", contentIntent); //10 is a random number I chose to act as the id for this notification notificationManager.notify(10, notification); } 

    Se você quiser triggersr a notificação local com grandes dados, ou seja, com text multilinha em notificação única com título, Ticker, ícone, som … use o seguinte código … Eu acho que irá ajudá-lo ..

      Intent notificationIntent = new Intent(context, ReminderListActivity.class); notificationIntent.putExtra("clicked", "Notification Clicked"); notificationIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP); // To open only one activity // Invoking the default notification service NotificationManager mNotificationManager; NotificationCompat.Builder mBuilder = new NotificationCompat.Builder( context); Uri uri = RingtoneManager .getDefaultUri(RingtoneManager.TYPE_NOTIFICATION); mBuilder.setContentTitle("Reminder"); mBuilder.setContentText("You have new Reminders."); mBuilder.setTicker("New Reminder Alert!"); mBuilder.setSmallIcon(R.drawable.clock); mBuilder.setSound(uri); mBuilder.setAutoCancel(true); // Add Big View Specific Configuration NotificationCompat.InboxStyle inboxStyle = new NotificationCompat.InboxStyle(); String[] events = null; events[0] = new String("Your first line text "); events[1] = new String(" Your second line text"); // Sets a title for the Inbox style big view inboxStyle.setBigContentTitle("You have Reminders:"); // Moves events into the big view for (int i = 0; i < events.length; i++) { inboxStyle.addLine(events[i]); } mBuilder.setStyle(inboxStyle); // Creates an explicit intent for an Activity in your app Intent resultIntent = new Intent(context, ReminderListActivity.class); TaskStackBuilder stackBuilder = TaskStackBuilder .create(context); stackBuilder.addPairentStack(ReminderListActivity.class); // Adds the Intent that stairts the Activity to the top of the stack stackBuilder.addNextIntent(resultIntent); PendingIntent resultPendingIntent = stackBuilder .getPendingIntent(0, PendingIntent.FLAG_CANCEL_CURRENT); mBuilder.setContentIntent(resultPendingIntent); mNotificationManager = (NotificationManager) context .getSystemService(Context.NOTIFICATION_SERVICE); // notificationID allows you to update the notification later on. mNotificationManager.notify(999, mBuilder.build()); }  Intent notificationIntent = new Intent(context, ReminderListActivity.class); notificationIntent.putExtra("clicked", "Notification Clicked"); notificationIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP); // To open only one activity // Invoking the default notification service NotificationManager mNotificationManager; NotificationCompat.Builder mBuilder = new NotificationCompat.Builder( context); Uri uri = RingtoneManager .getDefaultUri(RingtoneManager.TYPE_NOTIFICATION); mBuilder.setContentTitle("Reminder"); mBuilder.setContentText("You have new Reminders."); mBuilder.setTicker("New Reminder Alert!"); mBuilder.setSmallIcon(R.drawable.clock); mBuilder.setSound(uri); mBuilder.setAutoCancel(true); // Add Big View Specific Configuration NotificationCompat.InboxStyle inboxStyle = new NotificationCompat.InboxStyle(); String[] events = null; events[0] = new String("Your first line text "); events[1] = new String(" Your second line text"); // Sets a title for the Inbox style big view inboxStyle.setBigContentTitle("You have Reminders:"); // Moves events into the big view for (int i = 0; i < events.length; i++) { inboxStyle.addLine(events[i]); } mBuilder.setStyle(inboxStyle); // Creates an explicit intent for an Activity in your app Intent resultIntent = new Intent(context, ReminderListActivity.class); TaskStackBuilder stackBuilder = TaskStackBuilder .create(context); stackBuilder.addPairentStack(ReminderListActivity.class); // Adds the Intent that stairts the Activity to the top of the stack stackBuilder.addNextIntent(resultIntent); PendingIntent resultPendingIntent = stackBuilder .getPendingIntent(0, PendingIntent.FLAG_CANCEL_CURRENT); mBuilder.setContentIntent(resultPendingIntent); mNotificationManager = (NotificationManager) context .getSystemService(Context.NOTIFICATION_SERVICE); // notificationID allows you to update the notification later on. mNotificationManager.notify(999, mBuilder.build()); 
    Android is Google's Open Mobile OS, Android APPs Developing is easy if you follow me.