In my Android application, when I rotate the device (slide out the keyboard) then my Activity
is restarted (onCreate
is called). Now, this is proba
Instead of trying to stop the onCreate()
from being fired altogether, maybe try checking the Bundle
savedInstanceState
being passed into the event to see if it is null or not.
For instance, if I have some logic that should be run when the Activity
is truly created, not on every orientation change, I only run that logic in the onCreate()
only if the savedInstanceState
is null.
Otherwise, I still want the layout to redraw properly for the orientation.
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_game_list);
if(savedInstanceState == null){
setupCloudMessaging();
}
}
not sure if this is the ultimate answer, but it works for me.