i am developing an android app in which i've used tabhost for tabbar
in each tab i've hosted FragmentActivity which in turn hosts different fragments
i am getting data from server via network calls and while sending each call i've to send the authentication token (for which i make login call first) the authentication token gets automatically expired after 30 minutes..
now the issue is if the user presses home button while in the middle of the app the app goes to the background and if user again launches the app i.e brings it to foreground (say after 30 minutes or more) meanwhile the authentication token gets expired then network call fails....
how can i know when my app comes to foreground ????????
i've googled for this issue and the solutions i've got uptill now are
- use onCreate(), onPause(), onResume() methods but in my case i've got 5 different tabs and according to this solution i'll have to check each FragmentActivity's methods also these methods get called not only on App Resumption but also tab switching and initial creation of FragmentActivities....
- the second approach i've got is the use of ActivityManager
neither of the approaches suits me ............ m middle of my app and really need help