title: AlarmManager vs wake up
body: <p>This is my code:</p>
  
  <p>Activity:</p>
  
  <pre><code>@Override
  public void onCreate(Bundle savedInstanceState) {
  
  ...
  
  Intent intent = new Intent(this, MyReceiver.class);
  PendingIntent pendingIntent = PendingIntent.getBroadcast(
      this.getApplicationContext(), 234324243, intent, PendingIntent.FLAG_UPDATE_CURRENT);
  
  AlarmManager alarmManager = (AlarmManager) getSystemService(ALARM_SERVICE);
  
  alarmManager.set(AlarmManager.RTC_WAKEUP, System.currentTimeMillis()
      + (5 * 1000), pendingIntent);
  
  ...
  } 
  </code></pre>
  
  <p>BroadcastReceiver:</p>
  
  <pre><code>public class MyReceiver extends BroadcastReceiver {
  
  @Override
  public void onReceive(Context context, Intent intent) {
      Intent service = new Intent(context, StartNotificationService.class);
  
      context.startService(service);
  }
  </code></pre>
  
  <p>Service:</p>
  
  <pre><code>public class StartNotificationService extends Service {
  
  @Override
  public void onStart(Intent intent, int startId) {
      super.onStart(intent, startId);
  
      this.intent = intent;
      showNotification();
  }
  
  private void showNotification() {
      Date date = new Date(pror.getFirstMillis());
  
      Log.i("date", date.toString());
  
      Timer timer = new Timer();
      TimerTask timerTask = new TimerTask() {
          @Override
          public void run() {
              createNotification(contentTitle, contentText, tickerText);
  
              pror.calculateVak();
              pror.setFirstMillis(pror.getNextVak());
  
              createStatusBarNotification(contentTitle, contentText, tickerText);
          }
      };
      timer.schedule(timerTask, date);
  }
  
  }
  </code></pre>
  
  <p>AndroidManifest</p>
  
  <pre><code>&lt;uses-permission android:name="android.permission.VIBRATE" /&gt;
  &lt;uses-permission android:name="android.permission.WAKE_LOCK" /&gt;
  &lt;uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" /&gt;
  &lt;application
       android:icon="@drawable/icon"
      android:label="@string/app_name" &gt;
      &lt;activity android:name=".ShowSettingsActivity" /&gt;
  
      &lt;receiver android:name=".MyReceiver"/&gt; 
      &lt;service android:name=".service.StartNotificationService"/&gt;
  
      &lt;activity android:name=".PreferencesActivity" android:label="@string/app_name"&gt;
     &lt;/activity&gt;
      &lt;activity
          android:label="@string/app_name"
          android:name=".VakActivity" &gt;
          &lt;intent-filter &gt;
              &lt;action android:name="android.intent.action.MAIN" /&gt;
  
              &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
          &lt;/intent-filter&gt;
      &lt;/activity&gt;
  &lt;/application&gt;
  </code></pre>
  
  <p>When phone go to sleep, alarmManager can't start notification/service.</p>
  
  <p>If I leave my phone in the 'active' - unlock state, a notification is triggered at a certain time.</p>
  
  <p>Where I made mistake?</p>