title: Android: cannot receive Alarm inside the BroadcastReceiver
body: <p>I stucked on the following:</p>
  
  <p>I created simple helper which should to set alarm in the predefined time:</p>
  
  <p><strong>In activity:</strong></p>
  
  <pre><code>  private void setAlarm() {
          // TODO: Should be moved in the short time into BaseActivity Class ()
          // Add notification
          try {
              AlarmHelper ah = new AlarmHelper(this);
              ah.setAlarm();
              Logger.i("Alarm successfully Set");
          } catch(Exception e) {
              Logger.e(e.getMessage());
  
          }
      }
  </code></pre>
  
  <p><strong>Helper:</strong></p>
  
  <pre><code>public class AlarmHelper {
      private Context mCtx;
  
      public AlarmHelper(Context ctx) {
          mCtx = ctx;
      }
  
      public void setAlarm() {
          try {
              Calendar calendar = Calendar.getInstance();
  
              calendar.set(Calendar.MONTH, 8);
              calendar.set(Calendar.YEAR, 2015);
              calendar.set(Calendar.DAY_OF_MONTH, 27);
  
              calendar.set(Calendar.HOUR_OF_DAY, 14);
              calendar.set(Calendar.MINUTE, 52);
              calendar.set(Calendar.SECOND, 0);
              calendar.set(Calendar.AM_PM,Calendar.PM);
  
              Intent myIntent = new Intent(mCtx, AlarmBroadcastReceiver.class);
              AlarmManager alarmManager = (AlarmManager) mCtx.getSystemService(mCtx.ALARM_SERVICE);
              alarmManager.set(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(), PendingIntent.getBroadcast(mCtx,1,  myIntent, PendingIntent.FLAG_UPDATE_CURRENT));
          } catch(Exception e) {
              Logger.e(e.getMessage());
          }
      }
  </code></pre>
  
  <p><strong>Permissions:</strong></p>
  
  <pre><code>  &lt;!-- APP PERMISSIONS --&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.alarm.permission.SET_ALARM"/&gt;
      &lt;uses-permission android:name="android.permission.WAKE_LOCK"/&gt;
  </code></pre>
  
  <p><strong>Receiver</strong></p>
  
  <pre><code>   &lt;!-- BROADCAST RECEIVERS --&gt;
      &lt;receiver android:name=".receiver.AlarmBroadcastReceiver"
          android:enabled="true"
          android:exported="true"&gt;
      &lt;/receiver&gt;
  </code></pre>
  
  <p><strong>I tried also this:</strong></p>
  
  <pre><code> &lt;!-- BROADCAST RECEIVERS --&gt;
          &lt;receiver android:name="com.xxx.xxx.receiver.AlarmBroadcastReceiver"
              android:enabled="true"
              android:exported="true"&gt;
              &lt;intent-filter&gt;
                  &lt;action android:name="YOUR_NAME" /&gt;
              &lt;/intent-filter&gt;
          &lt;/receiver&gt;
  
  
  
  
  
  public class AlarmBroadcastReceiver extends BroadcastReceiver {
  
      @Override
      public void onReceive(Context context, Intent intent) {
          try {
              PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
              // Device battery life will be significantly affected by the use of this API.
              PowerManager.WakeLock wl = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "TAG");
              // Acquire the lock
              wl.acquire();
              Logger.d("ALARM RECEIVED!!!");
              //Release the lock
              wl.release();
          } catch (Exception e) {
              Logger.e("onReceive method cannot be processed");
              e.printStackTrace();
          }
      }
  }
  </code></pre>
  
  <p>No exception during the <strong>setAlarm</strong> method execution. But <strong>onReceive</strong> method is never executed. </p>
  
  <p>Where can be problem please?</p>
  
  <p>Many thanks for any advice.</p>