views:

28

answers:

2

I've downloaded a few networking apps (games) that have you log in, then take you to a "home" type screen where you can change your settings, or start a new game, or view your buddies etc.

My question is two-part:

1) how are these "multipanel" apps created? Is each panel its own activity? I've tried adding different panels through Views, but on the apps I described above, when I hit the back button on my phone, it takes me to the previous screen and in my apps, it just takes me out of the app when I hit back (again I'll I've done are add separate views). Can someone point me in the right direction of what I need to do to create a multipanel application that when I click a button, a new panel loads, then when I hit back on the phone, it takes me to the previous panel?

2) one of my panels will be a login page which I will post the log-in credentials via http post to my server for authentication. I would like to remember the log-in "token" that is passed back to the client so they don't have to log in every time they use my application. Again, referring to some of the apps that I have, they offer this feature but I can not locate anything on the phone where it would be saved. Is this done with xml usually?

Thanks for your time.

A: 

1) Yes, these are probably separate Activities. There's also a possibility that they're capturing the Back Button press and switching views, but that's a pretty awkward way to do it.

2) You can save the data with SharedPreferences or in an SqLite database.

BenTobin
A: 

1 - I agree. They are most likely separate Activities. To open another activity, you just use an intent, like this:

Intent intent = new Intent(MyActivity.this, NewActivity.class);
startActivity(intent); 

2 - It sounds like the SharedPreferences class is the way to go, but read through the Android documentation for storing data, since there are a number of ways to go about saving data:

http://developer.android.com/guide/topics/data/data-storage.html http://developer.android.com/reference/android/content/SharedPreferences.html

Computerish
great thanks for the response! based on your suggestions, I found this article which I'm reading now: http://www.linux-mag.com/id/7498 It looks to do both of what I asked about in my OP. Thanks again.
Kyle