How to call a method when user comes from outside of application but not when user is inside application
<p>I want to call a method specially when user restart activity after pressing home button.</p>

<p>i tried this but its not working</p>

<pre><code>@Override
 public void onRestart() {
    super.onRestart();
     // Do Here what ever you want do on back press;
    Log.d(TAG,"restart");
    blnIsApp=true;
 }
@Override
 public void onResume() {
     // Do Here what ever you want do on back press;        
    super.onResume();
    if(blnIsApp==false)
    {
        Log.d(TAG,"external");

    }else{
        Log.d(TAG,"internal");
    }
    blnIsApp=false;
 }
</code></pre>
