title: AlarmManager is not setting alarm in activity's oncreate
body: <p>I want to setup alarm on acitivty's <code>onCreate()</code> method to call a <code>Receiver</code> which starts a service to load data from website but the <code>AlarmManager</code> is not setting up the alarm and repeat that alarm for particular time interval Here is my code.
  This is <code>MainActivity</code> Code</p>
  
  <pre><code>@Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
          mNavigationDrawerFragment = (NavigationDrawerFragment) getFragmentManager()
                  .findFragmentById(R.id.navigation_drawer);
          mTitle = getTitle();
  
          // // Set up the drawer.
          // mNavigationDrawerFragment.setUp(R.id.navigation_drawer,
          // (DrawerLayout) findViewById(R.id.drawer_layout));
          mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
          // Set up the drawer.
          mNavigationDrawerFragment.setUp(R.id.navigation_drawer, mDrawerLayout);
          getFragmentManager().addOnBackStackChangedListener(
                  new OnBackStackChangedListener() {
  
                      @Override
                      public void onBackStackChanged() {
                          BaseFragment fragment = getActiveFragment();
                          if (fragment != null) {
                              fragment.resetActionBarTitle();
                          }
                      }
                  });
  
          setupAlarm();
      }
  
      private void setupAlarm() {
          // TODO Auto-generated method stub
          Intent i = new Intent(this, AlarmReciever.class);
          PendingIntent pendingIntent = PendingIntent.getBroadcast(this, 0, i, PendingIntent.FLAG_CANCEL_CURRENT);
          AlarmManager alarmManager = (AlarmManager) getSystemService(ALARM_SERVICE);
          alarmManager.setRepeating(AlarmManager.RTC_WAKEUP,
                  System.currentTimeMillis(), AlarmManager.INTERVAL_FIFTEEN_MINUTES, pendingIntent);
      }
  </code></pre>
  
  <p>This is AlarmReciever</p>
  
  <pre><code>public class AlarmReciever extends BroadcastReceiver {
      @Override
      public void onReceive(Context context, Intent intent) {
          // TODO Auto-generated method stub
          Log.d("onRecieve", "Reciever is executing");
          Intent i = new Intent(context, MyService.class);
          context.startService(i);
  
      }
  </code></pre>
  
  <p>And this is my <code>Service</code></p>
  
  <pre><code>public class MyService extends Service {
      Map&lt;String, String&gt; map;
      ServerDetails serverDetails;
  
      @Override
      public IBinder onBind(Intent intent) {
          // TODO Auto-generated method stub
          return null;
      }
  
      @Override
      public void onCreate() {
          // TODO Auto-generated method stub
          super.onCreate();
          Log.d("service Created", "service created");
          map = new HashMap&lt;String, String&gt;();
  
      }
  
      @SuppressWarnings("deprecation")
      @Override
      public void onStart(Intent intent, int startId) {
          // TODO Auto-generated method stub
          super.onStart(intent, startId);
          Log.d("service started", "service started");
          getStats();
  
      }
  
      private void getStats() {
          // TODO Auto-generated method stub
          System.out.print("get stats is executing");
          serverDetails = new ServerDetails(this);
          map.clear();
          Response.Listener&lt;String&gt; responseListner = new Response.Listener&lt;String&gt;() {
  
              @Override
              public void onResponse(String arg0) {
                  // TODO Auto-generated method stub
                  try {
                      JSONObject jobj = new JSONObject(arg0);
                      String result = jobj.getString("result");
                      if (result.contains("success")) {
                          map = new HashMap&lt;String, String&gt;();
                          map.put("result", result);
                          map.put("income_today", jobj.getString("income_today"));
                          map.put("income_thismonth",
                                  jobj.getString("income_thismonth"));
                          map.put("income_thisyear",
                                  jobj.getString("income_thisyear"));
                          map.put("tickets_open", jobj.getString("tickets_open"));
                          map.put("tickets_awaitingreply", String.valueOf(jobj
                                  .getInt("tickets_awaitingreply")));
                          map.put("cancellations_pending",
                                  jobj.getString("cancellations_pending"));
                          map.put("todoitems_due",
                                  jobj.getString("todoitems_due"));
                          map.put("networkissues_open",
                                  jobj.getString("networkissues_open"));
                          map.put("orders_pending",
                                  jobj.getString("orders_pending"));
                          map.put("billableitems_uninvoiced",
                                  jobj.getString("billableitems_uninvoiced")
                                          + " Overdue");
                      } else if (result.contains("error")) {
  
                      }
                  } catch (JSONException e) {
                      // TODO Auto-generated catch block
                      e.printStackTrace();
  
                  }
                  if (Integer.parseInt(map.get("tickets_awaitingreply")) &gt; 0) {
                      showNotification();
                  }
              }
          };
  
          StringRequest request = new StringRequest(Method.POST,
                  serverDetails.getUrl(), responseListner,
                  MyErrorListner.getListnerNoDialog(this)) {
  
              @Override
              protected Map&lt;String, String&gt; getParams() throws AuthFailureError {
                  // TODO Auto-generated method stub
                  Map&lt;String, String&gt; map = serverDetails.getParameters();
                  map.put("action", "getstats");
                  Log.d("params map in service", map.toString());
                  return map;
              }
  
          };
          AppController.getInstance().addToRequestQueue(request);
  
      }
  
      protected void showNotification() {
          // TODO Auto-generated method stub
          System.out.print("show notification is calling");
          Uri soundUri = RingtoneManager
                  .getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
          Intent intent = new Intent(this, MainActivity.class);
          PendingIntent pIntent = PendingIntent.getActivity(this, 0, intent, 0);
          @SuppressWarnings("deprecation")
          Notification mNofification = new Notification.Builder(this)
                  .setContentTitle("New Ticket")
                  .setContentText("New Tickets Awaiting Reply")
                  .setSmallIcon(R.drawable.ic_bill).setContentIntent(pIntent)
                  .setSound(soundUri)
                  /*
                   * .addAction(R.drawable.ic_bill, "View", pIntent) .addAction(0,
                   * "Remind", pIntent)
                   */.getNotification();
          NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
          notificationManager.notify(0, mNofification);
      }
  
  }
  </code></pre>