title: Override home Button in Android
body: <p>I need to override Home button for Lock Screen App. And I found the following answer which restart the app after 6 seconds on home button press.</p>
  
  <pre><code>protected void onUserLeaveHint() {
      Intent i=new Intent(this,MainActivity123.class);        
      startActivity(i.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT));
      Toast.makeText(this,"leaveHint",Toast.LENGTH_SHORT).show();
  }
  </code></pre>
  
  <p>But I want to start the app immediately. So I guess thier was an answer saying if we make our app default Launcher app than thier will be no time gap.So i added in my manifest </p>
  
  <pre><code>&lt;intent-filter&gt;
              &lt;action android:name="android.intent.action.MAIN" /&gt;
  
              &lt;category android:name="android.intent.category.HOME"/&gt;
              &lt;category android:name="android.intent.category.DEFAULT"/&gt;
              &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
          &lt;/intent-filter&gt;
  </code></pre>
  
  <p>But this is not working and app still restart after 6 sec.
  what should i do.</p>
  
  <p>So Spend some more researching and found another method {used to go to a default screen in launcher When you are already on home screen} 
  The method called automatically using appropriate flag in startActivity()</p>
  
  <pre><code>@Override
  protected void onNewIntent(Intent intent) {
      super.onNewIntent(intent);
      Toast.makeText(this,"onNewEvent",Toast.LENGTH_SHORT).show();
      if ((intent.getFlags() &amp; Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT) !=
              Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT) {
          Toast.makeText(this,"onNewEvent",Toast.LENGTH_SHORT).show();
          //++goHome++
          startActivity(intent);
      }
  }
  </code></pre>
  
  <p>The method is get called But app still starts after 6 sec. SO no progress Any suggestion........</p>