0

I am launching camera intent from my android application using this answer (I need user to be able to choose image from camera or from gallery)

But it seems that my whole app is recreated - activity's onCreate is called, and one of the classes, that is a singleton, has toString() value, that differs from the value before camera launch.

Here is also my activity description from android manifest:

<activity
            android:name="xxx"
            android:theme="@style/NoActionBarTheme"
            android:screenOrientation="portrait"
            android:configChanges="orientation|keyboardHidden|screenSize"
            android:label="@string/app_name">

</activity>

Any ideas what is going wrong?

Community
  • 1
  • 1
Mykhailo Granik
  • 368
  • 8
  • 23

2 Answers2

0

Make sure uncheck "Dont Keep Activities" from Developer Options in Settings.

Also check your manifest and code if your activity has correct launchMode.

Emre Aktürk
  • 3,306
  • 2
  • 18
  • 30
  • I checked it on the device, and "Dont Keep Activities" options is unchecked. In the question text I provided the description of this activity in the manifest, and the launch mode is a standard one. – Mykhailo Granik Nov 09 '15 at 15:44
-1

On some devices(i observed samsung s3), when launch camera app, device orientation is changed to landscape & again to portrait when select captured photo to return to our app. Our activity is re-created again & we end up as just started activity.

In this case, you have to implement following pair of callbacks for activity. OnSaveInstanceState() & OnRestoreInstaceState(). You can save member variables & restore them back when come back to your activity from camera app. e.g. imagePath (location you give for saving camera picture) can be saved & restored.

RaViMete
  • 161
  • 3
  • I am not sure it will work in this case, because it seems to me that the whole application is recreated (because of this strange thing, connected with recreation of the singleton class instance) – Mykhailo Granik Nov 09 '15 at 15:45