Reputation: 417
I am trying to create an android app for a website with user system (website that ask user to register to use the site - eg twitter,stackoverflow,etc).
So my app will require a user to either sign up or login in order to use.
To do this, I have implement the following steps:
1) Let user sign in from the app and send to http post
2) The server will create session on its side and send the session back to the app
3) App will keep the session - to manipulate data, the app will send the session to server to double check
Now the problem is: I have created several pages using intents. And if the user were to logout after signing in, and then they click the back button, they will be able to see the 'logged in' intent page.
Flow: User use app: Homepage--> (click on log in) --> Go to log in page (and enter info) --> Enter the login page --> click on user setting page --> edit setting (send to web server) and it says edit successfully --> click log out (app will then show the homepage again) --> problem when user click the 'back' button, they will be able to see the 'setting page'
I think it is the intent problem...if there is a way to have 1 intent to load all the pages, that would be good.
Is there a way to have 1 intent use to load several pages? If not, how can this be fix?
2nd Problem
Does each intent carries different web session? (like I login using Intent A and web server created a session, then I go to Intent B, will the session from Intent A be brought to Intent B?)
Upvotes: 1
Views: 3730
Reputation: 417
I found my answer. All you need is a singleton for the client.
The codes are found here: Android: Singleton DefaultHttpClient will not keep session
I created a BaseActivity so that all my other activity can use the client and make the httpPost request
Upvotes: 1