I am building an application in which user logs In, by using username and password, Activities other than LoginActivity must have a logout option. I have visited few threads here on SO regarding it an dhave some idea od how to do that programmatically however I cant think of “where to place this logout button ?”.
I would love to have a navigation or Action bar like popular activities i.e. Facebook for Android, Twitter for Android or Google Play store have. Since in future it will be easier to add additional features on this Action / Navigation bar. How should I proceed ? Any blog, tutorial or link will be of great help…
I am targeting Android 2.1+ devices. Here are some threads which I have already read…
Using same logout function in all activities
How to logout and many more… As a result got some idea about the back end logic (Using Intent and Intent filters etc.) for logout but can’t figure out the UI design.
EDIT
In some answers it is suggested to use ActionBar, However as I know it is available only after 3.0+, How I provide such functionality for 2.1+, please help… any tutorial, blog or guide will be of great help.. I don’t expect code just some pointers to start with…
One solution would be, include the logout button and if any layout associated with it, within
include tags in the layout file. Like
With this, you at least don’t have to create it multiple times.
To call it, in the click listener of the button, use a method with context as the parameter in a Global class. So that, you can call it from all the activities, avoiding the need for rewriting the code again.