0

OK I've had this problem for a while now. I'm developing a camera app that does some verification and uploads a photo to a website.

My problem is, I keep running into the question of making a chain of activities each returning a result on finishing to the previous activity, or making each activity return to the main activity, which spawns the next activity, depending on the result.

Here's an example: The main activity shows a photo gallery from which you can launch a camera preview. After capturing a photo, another activity opens where you can verify that you want to save that photo. After verifying, you are shown another activity which displays the progress of your upload. This could be implemented as a chain of startactivityforresults:

Gallery -> camera -> Verification -> Upload -> verification -> camera -> Gallery

OR as:

Gallery -> camera

camera -> Gallery

Gallery -> Verification

Verification -> Gallery

Gallery -> Upload

Upload -> Gallery

4

2 回答 2

1

Don't use an activity to show the upload progress. Use a ProgressDialog, or, better yet, offload the operation to an IntentService in the background. Remember to check for network connectivity before you attempt an upload!

As an alternative to "verifying" a save, you could do the save automatically and then allow the user to "undo" it. The UX guidelines suggest that the fewer interactions, the better, especially on small devices.

You could also save all the photos from a "session" to local storage, then allow the user to upload them later on, or asynchronously.

Besides that, you probably want separate activities/fragments if you want to allow the user to move back and forth at will between the steps, and have each step preserve its state.

In short, you should first spend some time thinking about what users do. Once you have some hazy model of how a user wants to use your app, then design it to achieve that. Too many developers rush off to build an app according to their understanding of the API. That approach is limiting.

于 2012-12-13T19:15:24.693 回答
0

Did you call activity.finish() every time you want to close your activity ? Do you use an AsyncTask class to perform your network communication and showing your upload progress bar and then start another Activity?

The AsyncTask class http://developer.android.com/reference/android/os/AsyncTask.html really help you to do such an operation: ActivityA -> Network connection and manipulation (running in backgroud) -> showing a progress bar or something like while performing the network communication(in your case uploading the photo) -> start another activity in the onPostexecute() methode of the AsyncTask!

This can really help you to have a stable transition from activities and a safe behaviour of your app !

I hope that this answer your question !

于 2012-12-19T00:01:35.263 回答