2

Hi I am developing one android application in which I am trying to check whether application is launch from recent task or not.Basically what I want to do, I want to show pin-code screen once user resume application from background. I tried with following things:

 if ((getIntent().getFlags() & Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY) != 0)
    {
        Log.i("******** BaseActivity", "******** BaseActivity onStart if launch from history ... "+Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY);
    }
    else
    {
        Log.i("******** BaseActivity", "******** BaseActivity onStart if not launch from history");
    }

Above thing always returns zero for FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY. Need some help. Thank you.

nilkash
  • 7,408
  • 32
  • 99
  • 176
  • 3
    This is work only when you launch the app from the recent not resume the app. If you finish your app by pressing back buttton and then launch again by pressing recent app lists, it will work. but if your app is not finish and just background to foreground then it will not work – bhavesh N Jun 20 '16 at 09:50
  • 4
    If you want to set some code that work on background to foreground the app. then you need to set some variable in onPause() method, so when app onResume() method is called you check those variable for apply your changes – bhavesh N Jun 20 '16 at 09:53
  • thx @bhaveshN you saved day!! – Jigar Fumakiya Aug 10 '18 at 12:05

0 Answers0