Я хочу получить ориентацию телефона, но сохраняю ориентацию экрана на портрете. Поэтому, независимо от того, как пользователь поворачивает телефон к пейзажу или портрету, вид остается прежним, но я могу получить, будет ли он повернут к пейзажу или портрету.
Настройка активности для android: screenOrientation = "портрет" будет исправлять оба, но я не смог бы определить ориентацию телефона через
public void onConfigurationChanged(Configuration newConfig) {
switch (newConfig.orientation) {
case Configuration.ORIENTATION_PORTRAIT:
Toast.makeText(this, "Portrait", Toast.LENGTH_SHORT).show();
break;
case Configuration.ORIENTATION_LANDSCAPE:
Toast.makeText(this, "Landscape", Toast.LENGTH_SHORT).show();
break;
default:
break;
}
}
Кто-нибудь знает, как это исправить?