title: Start new Activity after few seconds with BroadcastReceiver
body: <p>I would like to start new activity after few seconds with BroadcastReceiver. New Activity needs to be started even if the app is closed in the meantime.</p>
  
  <p>For now I have this but nothing happens when I run it:</p>
  
  <p>Main.java</p>
  
  <pre><code>@Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
  
      Button button = (Button) findViewById(R.id.button);
  
      button.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View view) {
              Intent intent = new Intent(getApplicationContext(), Receiver.class);
              PendingIntent pendingIntent = PendingIntent.getBroadcast(getApplicationContext(), 1, intent, 0);
              int seconds = 5;
              Calendar calendar = Calendar.getInstance();
              calendar.add(Calendar.SECOND, seconds);
              AlarmManager alarmManager = (AlarmManager) getSystemService(ALARM_SERVICE);
              alarmManager.set(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(), pendingIntent);;
          }
      });
  }
  </code></pre>
  
  <p>Receiver.java</p>
  
  <pre><code>public class Receiver extends BroadcastReceiver {
      private PowerManager.WakeLock mWakelock;
      @SuppressWarnings("deprecation")
      private KeyguardManager.KeyguardLock mLock;
      private static ContentResolver sResolver;
  
      @SuppressWarnings("deprecation")
      @Override
      public void onReceive(Context paramContext, Intent intent) {
  
          this.mWakelock = ((PowerManager) paramContext.getSystemService("power"))
                  .newWakeLock(805306394/* | PowerManager.ON_AFTER_RELEASE */,
                          "wakelock");
          this.mWakelock.acquire();
          this.mLock = ((KeyguardManager) paramContext
                  .getSystemService("keyguard")).newKeyguardLock("");
          this.mLock.disableKeyguard();
  
          setLockPatternEnabled(true);
  
          sResolver = paramContext.getContentResolver();
  
          Intent startMain;
          startMain = new Intent(paramContext, NewActivity.class);
          startMain.setAction("com.name.NewActivity");
          startMain.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
          paramContext.startActivity(startMain);
      }
  
      /**
       * used for to enable lock in all patterns
       *
       * @param enabled
       */
      @SuppressWarnings("deprecation")
      public static void setLockPatternEnabled(boolean enabled) {
          setBoolean(android.provider.Settings.System.LOCK_PATTERN_ENABLED,
                  enabled);
      }
  
      private static void setBoolean(String systemSettingKey, boolean enabled) {
          android.provider.Settings.System.putInt(sResolver, systemSettingKey,
                  enabled ? 1 : 0);
      }
  }
  </code></pre>
  
  <p>AndroidManifest.xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="com.name" &gt;
  
      &lt;uses-permission android:name="android.permission.DISABLE_KEYGUARD"/&gt;
  
      &lt;application
          android:allowBackup="true"
          android:icon="@mipmap/ic_launcher"
          android:label="@string/app_name"
          android:theme="@android:style/Theme.Light.NoTitleBar" &gt;
          &lt;activity
              android:name=".Main"
              android:label="@string/app_name" &gt;
              &lt;intent-filter&gt;
                  &lt;action android:name="android.intent.action.MAIN" /&gt;
  
                  &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
              &lt;/intent-filter&gt;
          &lt;/activity&gt;
  
          &lt;activity
              android:name="com.name.NewActivity"
              android:label="@string/app_name" &gt;
              &lt;intent-filter&gt;
                  &lt;action android:name="com.name.NewActivity" /&gt;
  
                  &lt;category android:name="android.intent.category.DEFAULT" /&gt;
              &lt;/intent-filter&gt;
          &lt;/activity&gt;
      &lt;/application&gt;
  
  &lt;/manifest&gt;
  </code></pre>
  
  <p>Does anyone know where is the problem? I also need that this new Activity unlocks the screen if it's locked, like alarm or call does.</p>