When an app activity is in landscape mode, and when a call comes in, the call will make the scene to portrait mode,
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_start_jum);
this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
}
after the call, the activity in the app that was in landscape mode gets destroy and created again.
D/StartJumActivity: onPause
D/StartJumActivity: onResume
D/StartJumActivity: onPause
D/StartJumActivity: onDestroy
D/StartJumActivity: on Create
The data in my activity gets removed and new activity is created. Is there any way to retain those data in that activity in landscape mode after returning from the call?
You could try forcing the orientation of the Activity
in the manifest:
android:screenOrientation="landscape"
This may prevent the Activity
from being destroyed and recreated.
Another alternative would be to tell Android that you will handle the orientation change yourself and not to recreate your Activity
on an orientation change. To do that add
android:configChanges="orientation"
to the manifest declaration for your Activity
. Now, when the screen orientation occurs, your Activity
will not be destroyed and recreated. Instead, onConfigurationChange()
will be called.