Reputation: 655
My question is related to android device problem.
We have an android device in our office: Samsung Galaxy Note 2 - GN7100 (Android version 4.1.2)
We use this devices for android development & testing purpose. But currently the device is creating some problem related to Android Life Cycle. For e.g. in the onCreate() method, we've downloaded data from backend, and now if we rotate the device onCreate() will call again, but we restricted calling onCreate() on device rotation by adding the following line into the tag:
android:configChanges="orientation|screenLayout|keyboardHidden"
It was working fine but suddenly this trick isn't working, i.e. the device calling the onCreate() method. Then I do factory reset, but the problem still exist.
My ques is: if this is device issue, then how can we correct it?
Thanks in advance.
Upvotes: 0
Views: 55
Reputation: 447
Try this
android:configChanges="keyboardHidden|orientation|screenSize"
and format your code.This worked for me
//Define Below in you Manifest file.
<activity
android:name="yourname"
android:configChanges="keyboardHidden|orientation|screenSize"
</activity>
//Define Below in your activity.
@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
if (newConfig.orientation == Configuration.ORIENTATION_PORTRAIT) {
//your code
} else if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) {
//your code
}
}
Upvotes: 1