title: How to show a notification even app is not running
body: <p>i'm beginner in android.i create a service to show a notification when onCreat on mainActivity called</p>
  
  <pre><code>    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);
      }
  
  }
  </code></pre>
  
  <p>here is my service class</p>
  
  <pre><code>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);
   }
  </code></pre>
  
  <p>but i want if my app is not running i can show this service for example if my phone time is bigger than 9 i show this notification only one time in a day.any ideas ? thanks in advance</p>