Alternative for UIAppDelegate in Android, a common code which will be called before any activity
We are building a security mechanism in our Android App, for which we need to ensure that we ask user for password every time they enter the app (even when it is running in background). For this I had to write the checks in all onRestart of every activity.
Looking for something similar to iPhone's AppDelegate where the code will be called before the activity and I can handle it in central place.
Let me know if more info is requir开发者_开发技巧ed.
The way i've done it in an app with similar functionality was the following:
- Create a BaseActivity class
- Overwrite the
OnStart()
here and implement your security - Extend all activities that need this with the BaseClass
This way you'll have a central place to do your security mechanisms.
精彩评论