title: Scheduled Alarm Manager not working Android
body: <p>I am trying to start an alarm service that repeats every day at a particular time. I have gone through a lot of threads on stack overflow regarding this but no luck. I followed a few tutorials: <a href="http://karanbalkar.com/2013/07/tutorial-41-using-alarmmanager-and-broadcastreceiver-in-android/" rel="noreferrer">http://karanbalkar.com/2013/07/tutorial-41-using-alarmmanager-and-broadcastreceiver-in-android/</a> and <a href="http://javatechig.com/android/repeat-alarm-example-in-android" rel="noreferrer">http://javatechig.com/android/repeat-alarm-example-in-android</a></p>
  
  <p>My service is never started and I do not understand why. Below is my code:</p>
  
  <p>My Manifest file:</p>
  
  <pre><code>     &lt;uses-sdk
              android:minSdkVersion="8"
              android:targetSdkVersion="17" /&gt;
  
          &lt;uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/&gt;
          &lt;uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/&gt;
          &lt;uses-permission android:name="android.permission.INTERNET"/&gt;
          &lt;uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /&gt;
          &lt;uses-permission android:name="android.permission.WAKE_LOCK" /&gt;
          &lt;uses-permission android:name="android.permission.CAMERA" /&gt;
          &lt;uses-permission android:name="com.android.alarm.permission.SET_ALARM" /&gt;
  &lt;application&gt;
          &lt;service android:name="com.paper.DownloadService" android:enabled="true"/&gt;
                    &lt;receiver android:name="com.paper.MyReceiver" &gt;&lt;/receiver&gt;
  &lt;/application&gt;
  </code></pre>
  
  <p>My Receiver Class:</p>
  
  <pre><code>public class MyReceiver extends BroadcastReceiver
  {      
      @Override
      public void onReceive(Context rcontext, Intent intent)
      {
          Log.e("Main Activity", "inside on receive of myreceiver");
         Intent service1 = new Intent(rcontext, DownloadService.class);
         rcontext.startService(service1);
  
      }   
  }
  </code></pre>
  
  <p>My Service Class:   </p>
  
  <pre><code> public class DownloadService extends Service {
      @Override
      public void onCreate() {
          // TODO Auto-generated method stub
          Log.e("Download Service", "CREATED");
      }   
      @SuppressLint({ "SimpleDateFormat", "NewApi" }) @Override
      public int onStartCommand(Intent intent, int flags, int startId) {
          // TODO Auto-generated method stub
  
          Log.e("Download Service", "STARTED");
          return START_NOT_STICKY;
      }
   }
  </code></pre>
  
  <p>My Main Activity (Inside On Create Method):</p>
  
  <pre><code>AlarmManager alarmManager = (AlarmManager) getSystemService(Context.ALARM_SERVICE);
  
              Calendar calendar = Calendar.getInstance();
              calendar.setTimeInMillis(System.currentTimeMillis());
              calendar.set(Calendar.HOUR_OF_DAY, 15);
              calendar.set(Calendar.MINUTE, 29);
  
               Intent myIntent = new Intent(this, MyReceiver.class);
               pendingIntent = PendingIntent.getBroadcast(this, 0, myIntent,0);
  
               alarmManager.setInexactRepeating(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(),
                       AlarmManager.INTERVAL_DAY, pendingIntent);
  </code></pre>
  
  <p>Here, I am trying to set up my alarm at 3:29 pm every day but the service does not get started at that time or any time for that matter. Any help would be appreciated. Thanks!</p>