Cómo mostrar una aplicación de notificación incluso no se está ejecutando

Soy principiante en android.i crear un servicio para mostrar una notificación cuando onCreat en mainActivity llamado

public class MainActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); Intent a = new Intent(this,myService.class); startService(a); } } 

Aquí está mi clase de servicio

 public class myService extends Service{ private NotificationManager mManager; @Override public void onCreate() { mManager = (NotificationManager) this.getApplicationContext().getSystemService(this.getApplicationContext().NOTIFICATION_SERVICE); Intent intent1 = new Intent(this.getApplicationContext(),MainActivity.class); Notification notification = new Notification(R.drawable.ic_launcher,"This is a test message!", System.currentTimeMillis()); intent1.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP| Intent.FLAG_ACTIVITY_CLEAR_TOP); PendingIntent pendingNotificationIntent = PendingIntent.getActivity( this.getApplicationContext(),0, intent1,PendingIntent.FLAG_UPDATE_CURRENT); notification.flags |= Notification.FLAG_AUTO_CANCEL; notification.setLatestEventInfo(this.getApplicationContext(), "AlarmManagerDemo", "This is a test message!", pendingNotificationIntent); mManager.notify(0, notification); } 

Pero quiero si mi aplicación no se está ejecutando puedo mostrar este servicio por ejemplo, si mi tiempo de teléfono es mayor que 9 i mostrar esta notificación sólo una vez en un day.any ideas? gracias por adelantado

Las notificaciones se ejecutan en segundo plano y no es necesario ejecutar la aplicación. Si bien la aplicación no se está ejecutando, las notificaciones también funcionan y esta es la misión principal de ellas. Le sugiero el tutorial y la documentación de Vogella:

http://www.vogella.com/tutorials/AndroidNotifications/article.html

http://developer.android.com/guide/topics/ui/notifiers/notifications.html

  1. No desea mostrar notificaciones mientras se ejecuta la aplicación. Eso es molesto y tiene (generalmente) ningún punto. Hay por supuesto excepciones.

  2. Si desea mostrar una notificación en un momento específico, debe considerar utilizar AlarmManager .

  3. Si desea activar la notificación desde un servidor o en cualquier otro lugar, utilice Google Cloud Messaging .

FlipAndroid es un fan de Google para Android, Todo sobre Android Phones, Android Wear, Android Dev y Aplicaciones para Android Aplicaciones.