title: BroadcastReceiver doesn't start activity when app closed
body: <p>So, I've been trying to achieve that for at least five hours today and I've tried literally ANY solution found anywhere.</p>
  
  <p>I'm programming a little clock app, using AlarmManager to make the app ring. It works fine when my app is open or minimized. I'm trying to make it work when the app is closed, and that's the problem. So, there is the piece of code that sets the AlarmManager :</p>
  
  <pre><code>    AlarmManager am = (AlarmManager) ctxt.getSystemService(Context.ALARM_SERVICE);
      Intent intent = new Intent(ctxt, AlarmService.class);
      PendingIntent pen = PendingIntent.getBroadcast(ctxt, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
      am.setExact(AlarmManager.RTC_WAKEUP, nextRing.getTime(), pen);
  </code></pre>
  
  <p>(Here, ctxt is the context, I've tried both getApplicationContext() and getBaseContext() and nextRing.getTime() is a long that represents the date)</p>
  
  <p>Then, I have my AlarmService class (wich used to be a service, which explain the name, but is now a BroadcastReceiver and I just don't want to rename it now)</p>
  
  <pre><code>public class AlarmService extends BroadcastReceiver {
  
    @Override
    public void onReceive(Context context, Intent intent) {
  
      /*Intent cust = new Intent(context, CustomIntent.class);
      context.startService(cust);*/
      Bundle extras = intent.getExtras();
      Intent newIntent = new Intent(context, AlarmActivity.class);
      newIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
      newIntent.putExtra("AlarmName", extras.getString("AlarmName"));
      context.startActivity(newIntent);
    }
  
  }
  </code></pre>
  
  <p>So this is the try with only the BroadcastReceiver, wich doesn't work obviously, so I tried to add a IntentService (commented out code at the top) which has the following code</p>
  
  <pre><code>public class CustomIntent extends IntentService {
    public CustomIntent() {
      super("CustomIntent");
    }
  
    @Override
    protected void onHandleIntent(Intent intent) {
      Intent newIntent = new Intent(getBaseContext(), AlarmActivity.class);
      newIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
      getApplication().startActivity(newIntent);
    }
  }
  </code></pre>
  
  <p>... and that's not working either ! Finally, here's the manifest I use :</p>
  
  <pre><code>&lt;application&gt;
  [Here goes stuff that have nothing to do with my bug]
      &lt;receiver android:name=".custom_classes.AlarmService"/&gt;
      &lt;service
        android:name="com.group9.abclock.custom_classes.CustomIntent"
        android:enabled="true" &gt;
        &lt;intent-filter&gt;
          &lt;action android:name="com.group9.abclock.custom_classes.CustomIntent" /&gt;
        &lt;/intent-filter&gt;
      &lt;/service&gt;
    &lt;/application&gt;
  </code></pre>
  
  <p>Sorry for the (very) long post but I tough I should explain anything I tried. Thanks in advance if you can help !</p>