We’ve been working on a webapp for some time now which is designed to be accessed solely through our Android app. Obviously, the App itself is extremely lightweight — mostly providing functionality for creating accounts and logging in, as well as make sure the webapp itself is only accessible through our Android app – BUT I digress…
The app is pretty dependent on PHP Session variables, which expire, and in the current testing environment, if your session expires you just get kicked out to the login screen anyway. But in production, the login screen will be on the Android app, completely independent of the WebView.
My idea right now is to have a Service run in the background which checks the timestamp we have in the database for a user’s last activity, and if it’s outside of a certain window, we close the webview. But if there was someway we could just exit the app after 15 minutes (or whatever) of inactivity–that would be preferable–or at least easier… I think…
Is there a way to do this — set up an auto timeout exit function? Or maybe exit the app with the onPause function?
Why a
Service?You do not want to exit the app. You want to go back to the login screen.
Check the timeout status in
onResume()of theWebView-hosting activity. If the activity is too old, callstartActivity()for your login screen, then callfinish()to close up theWebView-hosting activity.