title: add notification to To-do list in android?
body: <p>what i wanna do is , have a notification to inform user about upcoming task which has been added to todo list EVEN without opening the todo app  . i have used BroadcastReceiver by the way , because i have read android check them to see if there is any message has received by them.
  I know something is missing coz i have don everything in mainactivity.java so it would be done just by opening the app.</p>
  
  <p>here is my BroadcastReceiver file
  public class Broadcast extends BroadcastReceiver {</p>
  
  <pre><code>@Override
  public void onReceive(Context context, Intent intent) {
      // TODO Auto-generated method stub
  
      try {
          Bundle bundle = intent.getExtras();
          String message = bundle.getString("alarm_message");
          Toast.makeText(context, message, Toast.LENGTH_SHORT).show();
      } catch (Exception e) {
          Toast.makeText(
                  context,
                  "There was an error somewhere, but we still received an alarm",
                  Toast.LENGTH_SHORT).show();
          e.printStackTrace();
  
      }
  
      Toast.makeText(context, "received an alarm", Toast.LENGTH_SHORT).show();
  
  }
  </code></pre>
  
  <p>}</p>
  
  <p>and here is my mainactivity.java</p>
  
  <p>public class MainActivity extends Activity {</p>
  
  <pre><code>public NotificationCompat.Builder builder;
  public NotificationManager notificationManager;
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
  
      // NOTIFICATION
  
      AlarmManager alarmMang = (AlarmManager) getSystemService(ALARM_SERVICE);
  
      // ---get current date and time---
  
      Calendar calender = Calendar.getInstance();
      calender.add(Calendar.MINUTE, 5);
  
  
      Intent noteIntent = new Intent(this, Broadcast.class);
      PendingIntent pendI = PendingIntent.getActivity(this, 0, noteIntent, 0);
      long fireTime = System.currentTimeMillis();
  
      builder = new NotificationCompat.Builder(this)
              .setSmallIcon(R.drawable.ic_launcher)
              .setContentTitle("Notifications Example")
              .setContentText("This is a test notification");
  
      notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
  
      // // BUTTON NOT
      Button b = (Button) findViewById(R.id.button1);
      b.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View arg0) {
              // TODO Auto-generated method stub
              notificationManager.notify(0, builder.build());
          }
      });
  
      // // AET ALARM
  
  
  
      Toast.makeText(this, "lilili", Toast.LENGTH_SHORT).show();
      alarmMang.set(AlarmManager.RTC_WAKEUP, calender.getTimeInMillis(),
              pendI);
  
  
      notificationManager.notify(2332323, builder.build());
      // finish();
  
  }
  </code></pre>