title: Get Notification from Asynctask process
body: <p>I need to send notification from a background process.
  In this project I've tried to send a simple notification every 10 seconds.
  it runs but doesn't send the notification!</p>
  
  <pre><code>public class MainActivity extends ActionBarActivity {
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
          Long previousDate = new Long(System.currentTimeMillis());
          NotificationManager manager = (NotificationManager)getSystemService(Context.NOTIFICATION_SERVICE);
          new GetMethodEx1().execute(previousDate);
      }
  
      class GetMethodEx1 extends AsyncTask&lt;Long,Void,Void&gt;{
  
          private Context mContext;
          private int NOTIFICATION_ID = 1;
          private Notification mNotification;
          private NotificationManager mNotificationManager;
  
          @Override
          protected Void doInBackground(Long... params){
              Long previousDate = params[0];
              Long Intervall = new Long(System.currentTimeMillis());
              while ( true ){
                  if ((Intervall - previousDate) &gt; 10000 ){
                      String title = "Title";
                      String body = "Hi, I am the body";
                      createNotification( title, body);
                      previousDate = Intervall;
                  }
              }
              return null;
          }
  
          private void createNotification(String contentTitle, String contentText) {
  
              //Build the notification using Notification.Builder
              Notification.Builder builder = new Notification.Builder(mContext)
              .setSmallIcon(android.R.drawable.stat_sys_download)
              .setAutoCancel(true)
              .setContentTitle(contentTitle)
              .setContentText(contentText);
  
              //Get current notification
              mNotification = builder.getNotification();
  
              //Show the notification
              mNotificationManager.notify(NOTIFICATION_ID, mNotification);
          }
    // [ ... ]
    }
  </code></pre>
  
  <p>it don't crash but doesn't work!</p>