我正在尝试让我的Android应用程序在运行并修复旋转时立即旋转,我尝试了多种方法,比如:Settings.System.ACCELEROMETER_ROTATION --它不让它旋转,但是它只是启用了旋转功能,我需要您的帮助--提前感谢您(^_^)。这是我的代码:
`
TableRow tableRow;
Time HourProgram;
RotateAnimation r;
int H = 12000, M = 1200;
int averageConsultationTime = 30;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.table);
setAutoOrientationEnabled(this, true);
}
public static void setAutoOrientationEnabled(Context context,
boolean enabled) {
Log.i("OK", "setAutoOrientationEnabledOK");
Settings.System.putInt(context.getContentResolver(),
Settings.System.ACCELEROMETER_ROTATION, enabled ? 1 : 0);
}
public static boolean getRotationScreenFromSettingsIsEnabled(Context context) {
int result = 0;
try {
result = Settings.System.getInt(context.getContentResolver(),
Settings.System.ACCELEROMETER_ROTATION);
} catch (Settings.SettingNotFoundException e) {
e.printStackTrace();
}
return result == 1;
}`
发布于 2016-08-15 09:31:45
https://stackoverflow.com/questions/38952297
复制相似问题