N
N
nckma2013-11-21 22:02:02
Android
nckma, 2013-11-21 22:02:02

Is there a problem with Android Activity when the tablet is rotated?

In all the documentation, it seems to be written that when you rotate the Android tablet, its Activity will be recreated and data may be lost.
And it seems the same with Fragments that are inside an Activity.
My problem is that I just do not see that the data is lost. Can't see this documented situation.
In an application that I'm tinkering with (not written by me) in the C library, the native thread often calls a java class that is instantiated inside a Fragment.
Both in the emulator and in the real device, there are no problems either with turning or leaving the application in the background and returning back. Although it would seem that at the moment of recreating the Activity and Fragments, when the device is rotated, the native thread should sometimes refer to the destroyed instance of the Activity class and an exception should occur ..
I don’t understand how this can be?
Does this problem exist at all? Or is it only in older versions of android? Or is it only when the activity is low on memory being re-created?
It would seem - I don’t see a problem, the application works, but it’s somehow scary that the situation can still happen sometimes.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
Artem Kalachyan, 2013-11-21
@Bringoff

Oops, mixed up the tabs

P
Pavel, 2013-11-21
@FluffyMan

The data of controls located in the activity (maybe fragments, I won’t say for sure) is not lost if these controls have an id. Otherwise, the data of these controls is lost when the device screen orientation is changed.

N
niosus, 2013-11-26
@niosus

Check if the Fragmentattribute is set to isPersistant.
Also check the manifest for android:configChangesthings that make it so that the activity is not recreated when the screen is rotated.
Normal behavior - it is called in the activity onPauseand then immediatelyonResume

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question