Android dynamic disable or enable screen rotation tool, android dynamic
Package com. gwtsz. gts2.util; import android. content. context; import android. provider. settings;/*** gravity sensor switch * @ author Wilson */public class SensorUtil {/*** enable gravity sensing, that is, the screen can be rotated * @ param context */public static void openSensor (Context context) {Settings. system. putInt (context. getContentResolver (), Settings. system. ACCELEROMETER_ROTATION, 1);}/*** disable gravity sensing, which means that the screen cannot be rotated * @ param context */public static void closeSensor (Context context) {Settings. system. putInt (context. getContentResolver (), Settings. system. ACCELEROMETER_ROTATION, 0 );}}
Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.