title: Issue to resume Android Activity programmatically from background
body: <p>I tried to resume Android Activity programmatically from the background but when I press the home button the activity goes background after five seconds the activity launch again. working well with the back button and recent app button.</p>
  
  <p>Why its delay for five seconds to relaunch??</p>
  
  <p>API level is 19 and Android version is 4.4.2 (KitKat)</p>
  
  <p>Here is Code:</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.example.test.drawtoptest"&gt;
  
      &lt;application
          android:allowBackup="true"
          android:icon="@mipmap/ic_launcher"
          android:label="@string/app_name"
          android:supportsRtl="true"
          android:theme="@style/AppTheme"&gt;
          &lt;activity android:name=".MainActivity"
              android:launchMode="singleTop"&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=".Main2Activity"
              android:label="@string/app_name"
              android:parentActivityName=".Main2Activity"
              &gt;
          &lt;/activity&gt;
  
      &lt;/application&gt;
  
  &lt;/manifest&gt;
  </code></pre>
  
  <p><strong>MainActivity.class</strong></p>
  
  <pre><code>public class MainActivity extends AppCompatActivity {
  
    MyTimerTask myTimerTask;
      Timer timer;
      @Override
      protected void onCreate(Bundle savedInstanceState) {
  
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
          Button button = (Button) findViewById(R.id.button);
          Button button1 = (Button) findViewById(R.id.button3);
      }
    public void test(){
        Intent myIntent = new Intent(getBaseContext(), MainActivity.class);
          myIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP|Intent.FLAG_ACTIVITY_NEW_TASK|Intent.FLAG_ACTIVITY_SINGLE_TOP|Intent.FLAG_ACTIVITY_SINGLE_TOP);
          startActivity(myIntent);
      }
   class MyTimerTask extends TimerTask {
          @Override
          public void run() {
  
              test();
          }
      }
  
  
      @Override
      protected void onPause(){
          if (timer == null) {
              myTimerTask = new MyTimerTask();
              timer = new Timer();
              timer.schedule(myTimerTask, 50, 50);
          }
          super.onPause();
  
      }
  }
  </code></pre>