views:

89

answers:

1

I am working on an application that tries to streamline data entry from a very repetitive process:

  1. Enter some details that require full-screen graphics and would be confusing if scrolled
  2. Enter some more atomic details
  3. Enter yet more atomic details
  4. Apply the accumulated data
  5. Go back to step 1

I am pretty sure that i can represent this as 3 separate Activities and then just fire up new Intents for each activity in each cycle. What I can't yet get a sense of is whether this is a viable approach.

Question 1: If I do a fire-and-forget approach, how much of the resource management is going to be handled by Android? Will it just happily deallocate/reuse/etc. activities behind the scenes? Or is this something i have to manage myself?

Question 2: Is there a way to cause the reusing of activities so that only one instance of each activity is ever allocated and is just reused for each cycle?

Question 3: Can one manipulate the activity stack so that there aren't ~100 (approximated number of expected cycles) cycles worth of activities on the stack? I'd like to be able to use the back key no more than three times and exit out of the data entry portion to a summary page.

Question 4: Can anyone suggest alternate approaches to the cycles of activities problem? I have considered view flippers and tabs, but wasn't sure that would be better or not.

+2  A: 

Will it just happily deallocate/reuse/etc. activities behind the scenes?

Yes.

Is there a way to cause the reusing of activities so that only one instance of each activity is ever allocated and is just reused for each cycle?

Try FLAG_ACTIVITY_REORDER_TO_FRONT on your Intent to launch the activity. Based on the docs, it should give you your desired behavior.

Can one manipulate the activity stack so that there aren't ~100 (approximated number of expected cycles) cycles worth of activities on the stack?

100? You must be expecting some very patient users.

Regardless, FLAG_ACTIVITY_REORDER_TO_FRONT should cover that too.

Can anyone suggest alternate approaches to the cycles of activities problem? I have considered view flippers and tabs, but wasn't sure that would be better or not.

Tabs aren't great for things where you're trying to enforce a flow, since tabs are designed for random (not sequential) access. ViewFlipper/ViewSwitcher could work, though then you have to manage BACK button functionality and make sure you're not effectively leaking memory within the activity, since you're expecting people to be using it for an extended period.

CommonsWare
Thanks. Your response got me oriented in this area of Android (and its relevant configuration) and I can move forward again. I appreciate the time you took to respond.
ee
I'd vote for using FLAG_ACTIVITY_CLEAR_TOP when returning to the first activity instead. This will stop the user from being able to going back after applying/sending the data on the last activity.
alexanderblom
@alexanderblom - Yeah. Now that i see the operations for stack manipulation, i will probably mix and match things to get a good, intuitive user experience. Thanks for the suggestion.
ee
@alexanderblom: `FLAG_ACTIVITY_CLEAR_TOP` wipes out all other activities in the task, which violates Question #2. I agree that it's a good choice in many cases, though.
CommonsWare
@CommonsWare Docs says it will only clear activities on top of the targeted activity. His #2 only means that he doesn't want multiple versions of the the same activity in memory, which will never happen with FLAG_ACTIVITY_CLEAR_TOP
alexanderblom
@alexanderblom: His #2 explicitly says "the reusing of activities". `FLAG_ACTIVITY_CLEAR_TOP` will not reuse the activities that were cleared.
CommonsWare
Yeah, okay. But unless his activities are very complex (and therefore heavy on load) I'd advice him to stick with FLAG_ACTIVITY_CLEAR_TOP.
alexanderblom