title: NotificationManager.notify locks the phone and Emulator
body: <p><strong>PROBLEM:</strong></p>
  
  <p>The phone/emulator locks up on repeated Notification updates. The only way to get the emulator back responsive after it gets locked is by pressing Home => Menu => Lock => Home => Menu Button in that given order.</p>
  
  <p><strong>CODE:</strong></p>
  
  <p>Notification pushing code:</p>
  
  <pre><code>        // Set up notifcation views
          SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
          NotificationManager notificationManager = (NotificationManager)getSystemService(NOTIFICATION_SERVICE); // Get notification manager
          RemoteViews contentView = new RemoteViews(getPackageName(), R.layout.service_notification);
          contentView.setViewVisibility(R.id.current_error_text, View.GONE);
          contentView.setViewVisibility(R.id.error_text, View.GONE);
          contentView.setViewVisibility(R.id.info_error_text, View.GONE);
          contentView.setViewVisibility(R.id.info_text, View.GONE);
          contentView.setViewVisibility(R.id.next_check_in_text, View.VISIBLE);
          contentView.setViewVisibility(R.id.current_profile_text, View.VISIBLE);
          contentView.setViewVisibility(R.id.profile_name_text, View.VISIBLE);
          contentView.setTextViewText(R.id.next_check_in_text, mainText);
          // Set profile text now
          contentView.setTextViewText(R.id.profile_name_text, miniText);
          // Set up a new notification
          Notification notif = new Notification(R.drawable.service_logo_small, "Service is running", System.currentTimeMillis());
          notif.contentView = contentView; // Set content view
          // Create and plug in the PendingIntent
          Intent notifIntent = new Intent(this, EntryPointActivity.class);
          PendingIntent pIntent = PendingIntent.getActivity(this, 0, notifIntent, 0); // Set up the Pending Intent
          notif.contentIntent = pIntent;
          // Now set up notification flags
          notif.flags |= Notification.FLAG_NO_CLEAR;
          notif.flags |= Notification.FLAG_ONGOING_EVENT;
          notif.flags |= Notification.FLAG_FOREGROUND_SERVICE;
          if(sp.getBoolean("UpdateLights", true)) notif.flags |= Notification.DEFAULT_LIGHTS;
          if(sp.getBoolean("UpdateVibrate", true)) notif.flags |= Notification.DEFAULT_VIBRATE;
          if(sp.getBoolean("UpdateSound", true)) notif.flags |= Notification.DEFAULT_SOUND;
  
          notificationManager.notify(R.string.app_name, notif);
  </code></pre>
  
  <p>All objects exist and the project compiles perfectly. I encounter NO NullPointerExceptions!</p>
  
  <p>Code calling the notification creating function:</p>
  
  <pre><code>final Timer timer = new Timer();
  timer.scheduleAtFixedRate(new TimerTask(){
  @Override
  public void run() {
      if(( nextUpdateIn - System.currentTimeMillis() ) &gt; 0) {
          long milliseconds = (nextUpdateIn - System.currentTimeMillis());
          int seconds = (int) (milliseconds / 1000) % 60 ;
          int minutes = (int) ((milliseconds / (1000*60)) % 60);
          String toShow = "Next Check In: " + minutes + " minute" + ((minutes != 1) ? "s" : "") + " " + seconds + " second" + ((seconds != 1) ? "s" : "");
          pushNotification(STATE_LOADEDSUCCESSFULLY, currentProfile.getProfileName(), toShow);
      } else {
          currentState = STATE_RELOADING;
          pushNotification(STATE_RELOADING, null, "Refreshing..");
          timer.cancel();
      }
  }
  }, 1, 999);
  </code></pre>
  
  <p>Again, all objects exist!
  The notification <strong>IS UPDATED</strong> in the above process but it locks up <strong>BOTH THE EMULATOR AND PHONE</strong> as mentioned above!</p>
  
  <p><strong>AIM:</strong></p>
  
  <p>To update notification in the Status Bar to basically show a countdown till the next refresh.</p>
  
  <p>Please help me get rid of this error ASAP!</p>
  
  <p>Thanks in advance :)</p>
  
  <p>Regards,</p>
  
  <p>Akshit Soota</p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>I'm trying to run this code via a <strong>SERVICE</strong> and I've tried on emulators running Android 2.2, 2.3.3, 4.1 and all of them give me the same problem!</p>