Use the check on onCreate checkbox. Make flag = true during initialization / declaration add android: configChanges = "orientation" in ur manifest file
In the ur java file, override the onConfigurationChanged method and make the flag false.
After that ur onCreate will be called, but the mention of code in if will not be called. Move ur code inside if condition.
try using this.
static boolean flag = true; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); if(flag) Log.d("ONCREATE", "flag is true"); } @Override public void onConfigurationChanged(Configuration newConfig) { // TODO Auto-generated method stub Log.d("ONCONFIGCHANGE", "CALLED" ); flag = false; super.onConfigurationChanged(newConfig); }
Hardik4560
source share