When the user opens the application, there is a screen with a button on it, which says “login.”
The user clicks on the button, and a webview pops up to allow him to log in to the website.
After logging in (the app would need to know somehow), the webview would disappear, and then a list of usernames will pop up. (ListView?)
When the user clicks on one of the usernames, a webview of the username’s profile will pop up. Of course, when the user pushes “back”, it goes back to the list of usernames.
Can someone explain this to me in terms of Activity and Views? Am I using two activities to do this? Do I hide webview or listview when the user clicks between them?
I did the tutorial (notepad tutorial), but I’m still confused as to what is the best way to develop this.
Thanks
Yo can do this with two separate
Activityclasses. I would put theWebViewin its ownActivity. This is easier than managing lots of differentViewobjects yourself. Also, you’ll get transitions between different things if you put each part in its ownActivity.You’ll can launch the login
Activitywith thestartActivityForResult()method, allowing it to return if the login was successful or not.If you want to detect the login, you can monitor events in a
WebViewusing aWebViewClient. You set theWebViewClientof yourWebViewusing thesetWebViewClient()method.Simply start the next
Activityusing anIntentand call thefinish()method on your firstActivity. If you do this then the use won’t come back to login button Activity if they click back as it won’t be on the stack any more.What I’m not clear on is how long the login at the website will be valid for. You may need to set the flags on the Activities in your Manifest, to ensure the user has to log in again if they leave and then return to your application.
Use a
ListActivity. This is anActivitywhich comes with the API designed for displaying a singleListView.So use the
onListItemClick()method inListActivityto detect the touch and launch a newActivitycontaining theWebViewto show the profile. As this is in a newActivitythe back handling is all automatic.