title: Alarm Manager isn't working on Fragment
body: <p>In my Project  my class extending <code>Fragment</code>. I can't understand why <code>AlarmManager</code> doesn't work. In logcat it shows <code>NullPointerException</code>:</p>
  
  <pre><code>Intent myIntent = new Intent(context, AppService.class);
  pendingIntent = PendingIntent.getService(context, 0, myIntent, 0);
  AlarmManager alarmManager = (AlarmManager)getActivity().getSystemService(Context.ALARM_SERVICE);
  Calendar calendar = Calendar.getInstance();
  calendar.setTimeInMillis(System.currentTimeMillis());
  calendar.add(Calendar.SECOND, 10);
  alarmManager.setRepeating(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(), 10*1000, pendingIntent);
  Toast.makeText(getActivity().getApplicationContext(), "Start Alarm", Toast.LENGTH_LONG).show();
  </code></pre>