Summary of the invention
Based on this, it is necessary in view of the above technical problems, provide a kind of Android system terminal screen rotation method and
System reduces the electric energy that acceleration transducer needs to expend, and is conducive to the energy-saving effect and the feature of environmental protection that promote terminal.
A kind of screen rotation method of Android system terminal, comprising:
The state switched based on AMS service to screen rotation is monitored;Wherein, the screen rotation switch includes difference
Record corresponding open state closed state corresponding with when being closed when being opened;
When user enters interface, judge whether support screen rotates current interface by AMS service, and judge that screen revolves
Turn on the state of pass;
If current interface support screen rotates and screen rotation switch is in the open state, acceleration transducer is opened,
Screen rotation is executed to the interface to show.
A kind of screen rotation system of Android system terminal, comprising:
Module is listened to, the state for being switched based on AMS service to screen rotation is monitored;Wherein, the screen rotation
It turns on pass and includes open state corresponding when record is opened respectively closed state corresponding with when being closed;
Judgment module, for when user enters interface, judging current interface by AMS service, whether support screen to revolve
Turn, and judges the state of screen rotation switch;
Execution module, if being used for, current interface support screen rotates and screen rotation switch is in the open state, opens
Acceleration transducer executes screen rotation to the interface and shows.
The screen rotation method and system of above-mentioned Android system terminal services the shape switched to screen rotation based on AMS
State is monitored, and when user enters interface, determining current interface by AMS service is support screen rotation and screen rotation
When switching in the open state, it is then turned on acceleration transducer execution screen rotation and shows.It can reduce and not support to shield checking
The electric energy that acceleration transducer expends is opened when the interface of curtain rotation, improves the energy-saving effect and the feature of environmental protection of terminal.
Specific embodiment
With reference to the accompanying drawing to a kind of embodiment of the screen rotation method and system of Android system terminal of the invention
It is illustrated.
Technical solution of the present invention can be used on the terminal device of various Android systems, including smart phone, flat
Plate computer, PDA and other electronic equipments etc..
Refering to what is shown in Fig. 1, Fig. 1 is the screen rotation method flow diagram of Android system terminal of the invention, mainly include
Following steps:
S101, the state switched based on AMS service to screen rotation are monitored;Wherein, the screen rotation switch packet
Include record corresponding open state closed state corresponding with when being closed when being opened respectively;
In this step, pass through AMS (Activity Manager Service, the abbreviation in Android system terminal
AMS) in service, increase includes switching the service monitored to screen rotation, wherein screen rotation switch is divided into open state
And closed state, when open, it is " rotation_on " that state, which can be set, and upon closing, the state of can be set is
"rotation_off".AMS is the service that Android is responsible for administration interface, in android system, one Activity pairs
Answer an application window.
S102 judges whether support screen rotates current interface by AMS service, and judge when user enters interface
The state of screen rotation switch;
In this step, based in AMS service increased monitor function pass through when listening to user and entering interface
AMS service judges whether support screen rotates current interface, that is, first determines whether support screen rotates at the interface Activity, so
The state for judging screen rotation switch again afterwards, that is, judge whether user opens screen rotation switch.
As one embodiment, for by AMS service judge current interface whether support screen rotation the step of, can be with
The attribute of current interface is judged by AMS service call startActivityLocked function, if attribute is " undefined ",
Determine the rotation of current interface support screen.
The interface of Acvity can configure multiple attributes: " unspecified ", " sensor ", " user ",
" portrait ", " landscape ", respectively indicates: " undefined (default) ", " following sensor ", " are erected at " user's definition "
Directly ", " transverse screen " these attributes;The attribute of current interface is judged by AMS service call startActivityLocked function
Whether be " unspecified " can determine that current interface whether support screen rotation function.
S103 opens acceleration biography if current interface support screen rotates and screen rotation switch is in the open state
Sensor executes screen rotation to the interface and shows.
In this step, by the judgement of above-mentioned execution, if current interface support screen rotates, and screen rotation is switched
It is again in the open state, illustrate that user needs and is able to use screen rotation function, at this point, it is then turned on acceleration transducer,
It is shown using the state judgement of acceleration transducer to execute screen rotation to interface.
The screen rotation method and system of above-mentioned Android system terminal services the shape switched to screen rotation based on AMS
State is monitored, and when user enters interface, determining current interface by AMS service is support screen rotation and screen rotation
When switching in the open state, it is then turned on acceleration transducer execution screen rotation and shows.It can reduce and not support to shield checking
The electric energy that acceleration transducer expends is opened when the interface of curtain rotation, improves the energy-saving effect and the feature of environmental protection of terminal.
In one embodiment, refering to what is shown in Fig. 2, the screen of the Android system terminal of Fig. 2 another embodiment of the present invention
Spinning solution flow chart can also include step S100: the screen rotation switch of configurating terminal is switched with acceleration transducer
Work-based logic;Wherein, the work-based logic includes: to be latched the unlatching of acceleration transducer when screen rotation switch is opened.
The technical solution of above-described embodiment has modified the screen rotation switch and acceleration sensing of Android system terminal
Work-based logic relationship between device switch, when screen rotation switch is opened, recording status " rotation_on " is closed
When recording status " rotation_off ", not specifically execute acceleration transducer " sensor " opening operation;In this way into
Before the interface for entering support screen rotation, acceleration transducer will not be all turned on, to reduce power consumption.
Further, the work-based logic can also include: in the state that acceleration transducer is opened, if detected
Screen rotation switch is closed, then closes the acceleration transducer.
The technical solution of above-described embodiment, at any time, user close screen rotation switch, simultaneously close off acceleration biography
Sensor reduces power consumption.
In one embodiment, the screen rotation method of Android system terminal of the invention, when user enters interface branch
Screen rotation function is held, may also listen for being carrying out the interface that screen rotation is shown and then be closed when detecting that interface is exited
Acceleration transducer.
The technical solution of above-described embodiment then first closes acceleration transducer, at this time when interface sends variation (switching)
If entering another interface, then follow the steps S102, S103 and judged, then determines whether to open acceleration sensing
Device, as a result, interface change (switching) during or user enter not support screen rotation function, even if user does not have
Screen rotation switch is closed, acceleration transducer will not be opened, to reduce power consumption.
Refering to what is shown in Fig. 3, Fig. 3 is the screen rotation system structure diagram of Android system terminal of the invention, mainly
Include:
Module 101 is listened to, the state for being switched based on AMS service to screen rotation is monitored;Wherein, the screen
Rotary switch includes open state corresponding when record is opened respectively closed state corresponding with when being closed;
Judgment module 102, for when user enters interface, by AMS service judge current interface whether support screen
Rotation, and judge the state of screen rotation switch;
Execution module 103, if being used for, current interface support screen rotates and screen rotation switch is in the open state, opens
Acceleration transducer is opened, screen rotation is executed to the interface and is shown.
The technical solution of above-described embodiment, the screen rotation method and system of above-mentioned Android system terminal are based on AMS
It services the state for switching screen rotation to monitor, when user enters interface, determining current interface by AMS service is
When support screen rotation and screen rotation switch in the open state, it is then turned on acceleration transducer execution screen rotation and shows.
It can reduce and open the electric energy that acceleration transducer expends when checking the not interface of support screen rotation, improve the section of terminal
It can effect and the feature of environmental protection.
In one embodiment, refering to what is shown in Fig. 4, Fig. 4 is the Android system terminal of another embodiment of the present invention
Screen rotation system structure diagram can also include:
Configuration module 100, the work-based logic of screen rotation switch and acceleration transducer switch for configurating terminal;Its
In, the work-based logic includes: to be latched the unlatching of acceleration transducer when screen rotation switch is opened.
The technical solution of above-described embodiment has modified the screen rotation switch and acceleration sensing of Android system terminal
Work-based logic relationship between device switch, when screen rotation switch is opened, recording status " rotation_on " is closed
When recording status " rotation_off ", not specifically execute acceleration transducer " sensor " opening operation;In this way into
Before the interface for entering support screen rotation, acceleration transducer will not be all turned on, to reduce power consumption.
Further, the work-based logic can also include: in the state that acceleration transducer is opened, if detected
Screen rotation switch is closed, then closes the acceleration transducer.
The technical solution of above-described embodiment, at any time, user close screen rotation switch, simultaneously close off acceleration biography
Sensor reduces power consumption.
In one embodiment, the screen rotation system of Android system terminal of the invention, when user enters interface branch
Hold screen rotation function, execution module 103, which can be also used for monitoring, is carrying out the interface that screen rotation is shown, when detecting boundary
When face is exited, then acceleration transducer is closed.
The technical solution of above-described embodiment then first closes acceleration transducer, at this time when interface sends variation (switching)
If entering another interface, then judged by the correlation function of judgment module 102, execution module 103, then really
It is fixed whether to open acceleration transducer, as a result, during interface changes (switching) or user enters not support screen and revolves
Rotating function will not open acceleration transducer, disappear to reduce electric energy even if user is not turned off screen rotation switch
Consumption.
Each technical characteristic of embodiment described above can be combined arbitrarily, for simplicity of description, not to above-mentioned reality
It applies all possible combination of each technical characteristic in example to be all described, as long as however, the combination of these technical characteristics is not deposited
In contradiction, all should be considered as described in this specification.
The embodiments described above only express several embodiments of the present invention, and the description thereof is more specific and detailed, but simultaneously
It cannot therefore be construed as limiting the scope of the patent.It should be pointed out that coming for those of ordinary skill in the art
It says, without departing from the inventive concept of the premise, various modifications and improvements can be made, these belong to protection of the invention
Range.Therefore, the scope of protection of the patent of the invention shall be subject to the appended claims.