views:

63

answers:

3

I'm quite new to Android development and face UI implementation issues. Namely I'm trying to find a good way (design pattern?) that addresses view hierarchy and navigation between views (with history). Does is always has to be about launching new Activity? I don't want to learn bad habits during my first steps with Android SDK, hence my question. Your personal approaches you find good to follow or any links to resources/tutorials elaborating on the subject would be appreciated.

A: 

It is recomended you launch new Activities because it is the best way which Android is able to manage the cycle of live of tasks in your application.

You could make views on the fly and you could handle with setContentView() and a good controlling code for the events, but you will get a monolitic interface in a tangled mess.

Try to make a little analysis for the interface of your application with the user and it will show you the main screens and activities. It is easy, it is efficient... :)

caligari
+3  A: 

In Android, the recommended behavior is as such:

  1. The Back button returns you to a previous "screen". You don't always need to start a new Activity to create a new "screen", if you manage your own "sub-screen", you should override your Back button so it returns to the previous "sub-screen".
  2. User multitasks and when memory-constrained, the OS may kill your application. You should make sure users do not lose their unsaved work (e.g. partially filled forms) if the OS kills your application, your application should restore whatever the user is doing as if it's never killed when the user returns to your application. Assume that the user may go away at any time to do another activity (e.g. an urgent email notification comes up, and the user abandons your application to read the email), and behave appropriately.
  3. There is an UI design guideline regarding your question: http://developer.android.com/guide/practices/ui_guidelines/activity_task_design.html

Ironically, even Google admits that not all native applications behave this way. Some of the native applications violates the guideline due to conscious design decisions, while some just because historical reasons.

Lie Ryan
The link on UI design guidelines seems very interesting. Will get back with my feedback after I read it. Thank you, Lie :)
delirus
The article you suggested gave me a broad overview on UI design considerations, so I think it's an answer to my question as I can formulate my issue in Android terms :) Now I'm focusing on "Activities and Tasks" (developer.android.com), so I can address following: starting a task consisting of few activities ("screens"), which on BACK key returns to task's root activity. In other words: Activity1->A2->(TaskAct1->TA2->...->TAn)-(BACK)->A2, that is: any Task Activity navigates user to A2 on BACK. I think it's all about proper launching of tasks (affinities?) and stack manipulation. Am I correct?
delirus
A: 

I would recommend this books. http://commonsware.com/

If you are a Java beginner you should maybe consider learning Java first. Good books would be Head First Java or Thinking in Java for example.

After reading those books I'd recommend trying out online tutorials as you can learn a lot of things which are not that good whereas the quality of the books is great!

Octavian Damiean
Thanks for books suggestions :)
delirus