Android : update static int when value change in onConfigurationChanged

on Sunday, February 1, 2015


i declared public static int ii; on top of MainActivity.class



public class MainActivity extends Activity {

public static int ii;


and i am changing int value in onConfigurationChanged



@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
// Checks the orientation of the screen
if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) {
Toast.makeText(this, "landscape", Toast.LENGTH_SHORT).show();

ii=16;

} else if (newConfig.orientation == Configuration.ORIENTATION_PORTRAIT) {
Toast.makeText(this, "portrait", Toast.LENGTH_SHORT).show();

ii=8;

}
}


now the problem is, value is not updating from onConfigurationChanged to public static int ii;


i found something for string to update value: private static final String TAG = MainActivity.class.getSimpleName();


but i don't know how to implement something for integer to update value from onConfigurationChanged to public static int ii;


0 comments:

Post a Comment