1
내 안드로이드 기기의 자동 회전을 종료 또는 비활성화 할 토글 버튼을 만들려고합니다. 설정이 켜져 있거나 꺼지는 설정을 가져올 수있었습니다. 그러나 나는 설정을 바꿀 수 없습니다.회전 토글이 작동하지 않습니다.
public void toggleOrientation(View view)
{
ToggleButton tgOrientation = (ToggleButton) findViewById(R.id.tgOrientation);
String orientationOption = Settings.System.ACCELEROMETER_ROTATION;
int orientation = android.provider.Settings.System.getInt(getContentResolver(),orientationOption, 0);
if(orientation == 1)
{
android.provider.Settings.System.putInt(getContentResolver(),orientationOption,0);
tgOrientation.setChecked(false);
}
else
{
android.provider.Settings.System.putInt(getContentResolver(), orientationOption,1);
tgOrientation.setChecked(true);
}
}
내 코드에 문제가 있다면 누구에게 도와 줄 수 있습니까?
내 테스트 장치는 태블릿입니다. 도움이되는지 확실하지 않습니다. setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_FULL_SENSOR);
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
: setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_NOSENSOR);
디바이스/사용자가 방향을 결정하도록 :