Max Ehrlich
Max Ehrlich

Reputation: 2525

Managing Several Activities

I am having some trouble managing several activities in an Android app I am building. The app is designed to get an image from the camera, then upload the image a server for processing and display the result.

When my app starts, the initial activity launches the standard Camera activity so that the user can take a picture. Right now I am doing this in onStart of my activity. Of course this means that if the user rotates the phone mid-picture (or drops to the background and then comes back), my activity is destroyed and recreated launching a new instance of the Camera activity. If the user continues with the initial Camera activity, the image is sent back to my stopped activity and can't pass its data to the uploader activity. The user is then given to the second Camera activity.

Then, when the image is passed to the upload activity, the file is uploaded asynchronously starting again in the onStart function. This has the same problem of multiple uploads starting when the user rotates the phone.

What is the best way to handle a situation like this? Is it appropriate to restrict the orientation on these screens to portrait? It would be nice to at least let the camera activity rotate.

Upvotes: 1

Views: 42

Answers (1)

user1525382
user1525382

Reputation:

use android:configChanges="keyboardHidden|orientation|screenSize" in tag activity in manifest file .this cause activity dont run with orientation again

Upvotes: 1

Related Questions