CN114546541A - Method and system for accurately acquiring screen service time of Android device - Google Patents

Method and system for accurately acquiring screen service time of Android device Download PDF

Info

Publication number
CN114546541A
CN114546541A CN202210156530.XA CN202210156530A CN114546541A CN 114546541 A CN114546541 A CN 114546541A CN 202210156530 A CN202210156530 A CN 202210156530A CN 114546541 A CN114546541 A CN 114546541A
Authority
CN
China
Prior art keywords
time
screen
application
foreground
limit value
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202210156530.XA
Other languages
Chinese (zh)
Inventor
郑巧
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Shanghai Simcom Ltd
Original Assignee
Shanghai Simcom Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Shanghai Simcom Ltd filed Critical Shanghai Simcom Ltd
Priority to CN202210156530.XA priority Critical patent/CN114546541A/en
Publication of CN114546541A publication Critical patent/CN114546541A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/448Execution paradigms, e.g. implementations of programming paradigms
    • G06F9/4482Procedural
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/451Execution arrangements for user interfaces

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Human Computer Interaction (AREA)
  • Telephone Function (AREA)

Abstract

The invention relates to a method and a system for accurately acquiring the service time of a screen of an Android device, wherein the method comprises the following steps: acquiring a UsageEvents object of the Android equipment through a UsageStatsManager. queryEvents interface; acquiring information of all applications in the UsageEvents moving to the foreground and moving to the background; calculating the stay time of the application in the foreground by using the information of all the applications moved to the foreground and the background; the length of time that all applications stay in the foreground is summed to get the screen usage time. The invention has no influence on a time zone and can accurately acquire the data in the appointed time period. The interface of the system level is used by the invention, the system can be prevented from being killed, and the probability of data distortion caused by factors such as process killing, system time change and the like is very low.

Description

Method and system for accurately acquiring screen service time of Android device
Technical Field
The invention relates to the technical field of communication, in particular to a method and a system for accurately acquiring the service time of an Android device screen.
Background
In the Android device, a developer wants to conveniently know the duration of using the mobile phone application in a certain period of time by displaying the screen use time information of the device, so that the work and rest time of the developer is reasonably arranged. The common method for acquiring the screen use time is to call a system usagestats.gettotaltetitimeinfoforegorund () interface to directly acquire the screen use time and realize statistics of one Service by the user. However, the two modes often cause inaccurate use time of the acquired screen due to the fact that the process is killed, the time zone is changed, the system time is changed, and the like.
Disclosure of Invention
The invention aims to overcome the defects of the prior art, provides a method and a system for accurately acquiring the service time of an Android device screen, and solves the problem that the acquired service time of the screen is inaccurate due to the fact that a process is killed, a time zone is changed, system time is changed and the like in the conventional mode.
The technical scheme for realizing the purpose is as follows:
the invention provides a method for accurately acquiring the service time of a screen of an Android device, which comprises the following steps:
acquiring a UsageEvents object of the Android equipment through a UsageStatsManager. queryEvents interface;
acquiring information of all applications in the UsageEvents moving to the foreground and moving to the background;
calculating the stay time of the application in the foreground by using the information of all the applications moved to the foreground and the background; and
the length of time that all applications stay in the foreground is summed to get the screen usage time.
The invention obtains the service time of the screen through the UsagStatsManager. queryEvents interface, has no influence on a time zone, and can accurately obtain data in a specified time period. The method of the invention uses the interface of the system level, can avoid being killed by the system, and has small probability of data distortion caused by factors such as process killing, system time change and the like.
The method for accurately acquiring the screen service time of the Android device is further improved in that when the time length of the application staying in the foreground is calculated, the time length of the application moving to the background is subtracted from the time length of the application moving to the foreground to calculate the time length of the application moving to the foreground.
The method for accurately acquiring the service time of the Android device screen is further improved in that the method further comprises the following steps:
and carrying out statistical analysis on the information of each application moving to the foreground and the background so as to obtain the starting times and the starting duration of each application.
The method for accurately acquiring the service time of the Android device screen is further improved in that the method further comprises the following steps:
setting a use frequency limit value of an application;
and comparing the starting times of the application with the use time limit value, and forbidding the application to start when the starting times of the application reach the use time limit value.
The method for accurately acquiring the service time of the Android device screen is further improved in that the method further comprises the following steps:
setting a screen use limit value;
and comparing the screen use time with the screen use limit value, and closing the screen of the Android device when the screen use time reaches the screen use limit value.
The invention also provides a system for accurately acquiring the service time of the Android device screen, which comprises the following steps:
the device comprises an object acquisition unit, a task execution unit and a task execution unit, wherein the object acquisition unit is used for acquiring a UsageEvents object of the Android equipment through a UsageStasManager.
The event reading unit is connected with the object acquisition unit and used for acquiring information of all applications in the UsageEvents moving to the foreground and moving to the background;
the duration calculation unit is connected with the event reading unit and used for calculating the duration of the stay of the application in the foreground by utilizing the information of all the applications moved to the foreground and the background; and
and the processing unit is connected with the duration calculation unit and is used for summing the durations of the stay of all the applications in the foreground to obtain the service time of the screen.
The system for accurately acquiring the service time of the Android device screen is further improved in that the duration calculation unit calculates the duration of the stay of the application in the foreground by subtracting the event occurrence time of the application moving to the foreground from the event occurrence time of the application moving to the background.
The system for accurately acquiring the service time of the Android device screen is further improved in that the processing unit is also connected with the event reading unit and is further used for carrying out statistical analysis on information of each application moving to the foreground and moving to the background so as to obtain the starting times and each starting time of each application.
The system for accurately acquiring the service time of the Android device screen is further improved in that the processing unit is further used for receiving the set service time limit value of the application;
and the processing unit compares the starting times of the application with the use time limit value, and prohibits the application from starting when the starting times of the application reach the use time limit value.
The system for accurately acquiring the service time of the Android device screen is further improved in that the processing unit is further used for receiving the set screen service limit value;
and the processing unit compares the screen service time with the screen service limit value, and closes the screen of the Android device when the screen service time reaches the screen service limit value.
Drawings
FIG. 1 is a flowchart of a method for accurately acquiring the service time of a screen of an Android device.
FIG. 2 is a system diagram of the system for accurately acquiring the screen service time of the Android device.
Detailed Description
The invention is further described with reference to the following figures and specific examples.
Referring to fig. 1, the invention provides a method and a system for accurately acquiring the Service time of an Android device screen, which solve the problems that the acquisition of the Service time of the screen by using a user stats interface mode of gettotaltetitimelnformateground () is susceptible to a time zone and cannot accurately acquire data in a specified time period, and also solve the problem that the acquisition of the Service time of the screen by using self-defined Service is susceptible to process killing, system time change and other factors, which cause data distortion. The method and the system for acquiring the screen use time have no time zone limitation, can accurately acquire the data in the specified time period, and have low possibility of process killing because a system-level interface is used, thereby causing low probability of data distortion. The method and the system for accurately acquiring the service time of the Android device screen are described below with reference to the accompanying drawings.
Referring to fig. 1, a flowchart of a method for accurately acquiring the screen service time of an Android device is shown. The method for accurately acquiring the service time of the Android device screen is described below with reference to fig. 1.
As shown in fig. 1, the method for accurately obtaining the screen service time of the Android device includes the following steps:
executing step S11, acquiring a UsageEvents object of the Android device through a usagestatmanagerqueyevents interface; then, step S12 is executed;
executing the step S12, and acquiring information of all applications in the UsageEvents moving to the foreground and moving to the background; then, step S13 is executed;
executing step S13, calculating the stay time of the application in the foreground by using the information of all the applications moving to the foreground and moving to the background; then, step S14 is executed;
step S14 is executed to sum the lengths of time that all applications stay in the foreground to obtain the screen usage time.
The UsageEvents object of the Android equipment is obtained by calling a UsageStatsManager. queryEvents () interface, and all activity event information of all applications in a specified time period is contained in the UsageEvents object. And traversing the UsageEvents object to obtain the event information of all the applications moving to the foreground and the background, and calculating the staying time of each application on the foreground to obtain the screen using time. The UsageStatsService is a system-level process, and the Android system can not kill the process, so that the method for acquiring the screen service time is not easy to kill by the process, and the screen service time can be accurately acquired.
In a specific embodiment of the present invention, when calculating the time length that the application stays in the foreground, the time length is calculated by subtracting the time length that the application moves to the foreground from the time length that the application moves to the background.
And obtaining the stay time of the application in the foreground through the time difference between the occurrence time of the application moving to the background event and the occurrence time of the application moving to the foreground event.
In one embodiment of the present invention, the method further comprises:
and carrying out statistical analysis on the information of each application moving to the foreground and the background so as to obtain the starting times and the starting duration of each application.
The starting times and the starting duration of each application are displayed together with the corresponding application so as to be convenient for a user to check, the display form can be displayed in a digital list form, and can also be displayed in a chart form, so that the user can easily know the application use condition of the mobile phone in a certain period of time.
Further, still include:
setting a use frequency limit value of an application;
and comparing the starting times of the application with the use time limit value, and forbidding the application to start when the starting times of the application reach the use time limit value.
The use times of the application are limited, so that the user can be effectively helped to manage the use of the application, for example, the game can be set to be used for 1 time per day, and after the game is started for 1 time, the game cannot be started again in the same day. Preferably, the usage limit of the application is set by manual input from the user.
In one embodiment of the present invention, the method further comprises:
setting a screen use limit value;
and comparing the screen use time with the screen use limit value, and closing the screen of the Android device when the screen use time reaches the screen use limit value.
The screen use limit value is the limit value of the screen use time, and helps a user to manage the use time of the mobile phone. Preferably, the screen usage limit is set by a user by manual input.
According to the UsageStatsManager. queryEvents () interface called by the method, after the Android equipment modifies the time zone and modifies the system time, the queryEvents () interface can accurately acquire the event information in the time range to be queried, namely the time in the applied activity event information is consistent with the time of the Android equipment, so that the time zone problem does not exist.
In one embodiment of the present invention, the method further comprises:
setting a time period;
and acquiring the screen use time in a set time period.
Preferably, the set time period is manually input by the user.
The invention also provides a system for accurately acquiring the service time of the screen of the Android device, and the system is explained below.
As shown in fig. 2, the system for acquiring screen use time of the present invention includes an object acquisition unit 21, an event reading unit 22, a duration calculation unit 23, and a processing unit 24; the object acquisition unit 21 is connected with the event reading unit 22, the duration calculation unit 23 is connected with the event reading unit 22, and the processing unit 24 is connected with the duration calculation unit 23; the object acquisition unit 21 is used for acquiring a UsageEvents object of the Android device through a UsageStasManager. queryEvents interface; the event reading unit 22 is used for acquiring information of all applications in the UsageEvents moving to the foreground and moving to the background; the duration calculation unit 23 is configured to calculate a duration that the application stays in the foreground by using information of all applications moving to the foreground and moving to the background; the processing unit 24 is used to sum the lengths of time that all applications stay in the foreground to get the screen usage time.
In an embodiment of the present invention, the duration calculating unit 23 calculates the duration of the application staying in the foreground by subtracting the event occurrence time of the application moving to the background from the event occurrence time of the application moving to the foreground.
In an embodiment of the present invention, the processing unit 24 is further connected to the event reading unit 22, and is further configured to perform statistical analysis on information of each application moving to the foreground and moving to the background, so as to obtain the number of times of starting each application and the duration of each start.
Further, the processing unit 24 is further configured to receive a set usage number limit of the application;
the processing unit 24 compares the start-up frequency of the application with the use frequency limit value, and prohibits the start-up of the application when the start-up frequency of the application reaches the use frequency limit value.
In one embodiment of the present invention, the processing unit 24 is further configured to receive a set screen usage limit value;
the processing unit 24 compares the screen use time with the screen use limit value, and closes the screen of the Android device when the screen use time reaches the screen use limit value.
Further, the processing unit 24 is further configured to receive a set time period, and sum the lengths of time that the applications stay in the foreground within the set time period to obtain the screen usage time.
The system for accurately acquiring the service time of the Android device screen is application software which can be installed on the Android device, an input frame is arranged on a software interface after the software is started, so that a user can conveniently input a required set time period, an application use time limit value and a screen use limit value, the software can count the application use condition and the screen use time of the set time period and display the application use condition and the screen use time to the user for viewing after the user authorizes the software, the application use time and the screen use time can be managed according to the setting of the user, and the application and the screen are forbidden when the limit value is reached.
While the present invention has been described in detail and with reference to the embodiments thereof as illustrated in the accompanying drawings, it will be apparent to one skilled in the art that various changes and modifications can be made therein. Therefore, certain details of the embodiments are not to be interpreted as limiting, and the scope of the invention is to be determined by the appended claims.

Claims (10)

1. A method for accurately acquiring the service time of an Android device screen is characterized by comprising the following steps:
acquiring a UsageEvents object of the Android equipment through a UsageStatsManager. queryEvents interface;
acquiring information of all applications in the UsageEvents moving to the foreground and moving to the background;
calculating the stay time of the application in the foreground by using the information of all the applications moved to the foreground and the background; and
the length of time that all applications stay in the foreground is summed to get the screen usage time.
2. The method for accurately acquiring the screen service time of the Android device as claimed in claim 1, wherein the screen service time of the Android device is calculated by subtracting the event occurrence time of the application moving to the foreground from the event occurrence time of the application moving to the background when the time of the application staying in the foreground is calculated.
3. The method for accurately acquiring the screen usage time of the Android device according to claim 1, further comprising:
and carrying out statistical analysis on the information of each application moving to the foreground and the background so as to obtain the starting times and the starting duration of each application.
4. The method for accurately acquiring the screen usage time of the Android device according to claim 3, further comprising:
setting a use frequency limit value of an application;
and comparing the starting times of the application with the use time limit value, and forbidding the application to start when the starting times of the application reach the use time limit value.
5. The method for accurately acquiring the screen usage time of the Android device according to claim 1, further comprising:
setting a screen use limit value;
and comparing the screen use time with the screen use limit value, and closing the screen of the Android device when the screen use time reaches the screen use limit value.
6. The system for accurately acquiring the service time of the screen of the Android device is characterized by comprising the following steps:
the device comprises an object acquisition unit, a task execution unit and a task execution unit, wherein the object acquisition unit is used for acquiring a UsageEvents object of the Android equipment through a UsageStasManager.
The event reading unit is connected with the object acquisition unit and used for acquiring information of all applications in the UsageEvents moving to the foreground and moving to the background;
the duration calculation unit is connected with the event reading unit and used for calculating the duration of the stay of the application in the foreground by utilizing the information of all the applications moved to the foreground and the background; and
and the processing unit is connected with the duration calculation unit and is used for summing the durations of the stay of all the applications in the foreground to obtain the service time of the screen.
7. The system for accurately obtaining the screen usage time of the Android device as claimed in claim 6, wherein the duration calculation unit calculates the duration of the application staying in the foreground by subtracting the event occurrence time of the application moving to the foreground from the event occurrence time of the application moving to the background.
8. The system for accurately obtaining the screen usage time of the Android device of claim 6, wherein the processing unit is further connected to the event reading unit, and is further configured to perform statistical analysis on information of each application moving to a foreground and moving to a background to obtain the number of times each application is started and the duration of each start.
9. The system for accurately acquiring the screen usage time of the Android device according to claim 8, wherein the processing unit is further configured to receive a set usage time limit value of the application;
and the processing unit compares the starting times of the application with the use time limit value, and prohibits the application from starting when the starting times of the application reach the use time limit value.
10. The system for accurately acquiring the screen usage time of the Android device of claim 6, wherein the processing unit is further configured to receive a set screen usage limit value;
and the processing unit compares the screen service time with the screen service limit value, and closes the screen of the Android device when the screen service time reaches the screen service limit value.
CN202210156530.XA 2022-02-21 2022-02-21 Method and system for accurately acquiring screen service time of Android device Pending CN114546541A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210156530.XA CN114546541A (en) 2022-02-21 2022-02-21 Method and system for accurately acquiring screen service time of Android device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210156530.XA CN114546541A (en) 2022-02-21 2022-02-21 Method and system for accurately acquiring screen service time of Android device

Publications (1)

Publication Number Publication Date
CN114546541A true CN114546541A (en) 2022-05-27

Family

ID=81675598

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210156530.XA Pending CN114546541A (en) 2022-02-21 2022-02-21 Method and system for accurately acquiring screen service time of Android device

Country Status (1)

Country Link
CN (1) CN114546541A (en)

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104980565A (en) * 2014-04-09 2015-10-14 小米科技有限责任公司 Terminal anti-addiction method and device
CN107608853A (en) * 2017-09-06 2018-01-19 广东欧珀移动通信有限公司 Control method, device, storage medium and the intelligent terminal of terminal usage time
CN111479016A (en) * 2020-04-07 2020-07-31 Oppo广东移动通信有限公司 Terminal use duration reminding method and device, terminal and storage medium
CN112118345A (en) * 2019-06-19 2020-12-22 朱德全 Time management method for juveniles mobile phone
CN112732546A (en) * 2021-01-28 2021-04-30 腾讯科技(深圳)有限公司 Application-based use duration processing method, device, equipment and storage medium

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104980565A (en) * 2014-04-09 2015-10-14 小米科技有限责任公司 Terminal anti-addiction method and device
CN107608853A (en) * 2017-09-06 2018-01-19 广东欧珀移动通信有限公司 Control method, device, storage medium and the intelligent terminal of terminal usage time
CN112118345A (en) * 2019-06-19 2020-12-22 朱德全 Time management method for juveniles mobile phone
CN111479016A (en) * 2020-04-07 2020-07-31 Oppo广东移动通信有限公司 Terminal use duration reminding method and device, terminal and storage medium
CN112732546A (en) * 2021-01-28 2021-04-30 腾讯科技(深圳)有限公司 Application-based use duration processing method, device, equipment and storage medium

Non-Patent Citations (4)

* Cited by examiner, † Cited by third party
Title
LIUWAN1992: "关于 UsageStatsManager.queryUsageStats 的注意事项及 UsageStatsService 的简单原理", pages 1 - 5, Retrieved from the Internet <URL:《https://blog.csdn.net/liuwan1992/article/details/83625520》> *
LUCAS-HAO: "Android获取应用使用时长和次数-UsageStatsManager使用", pages 1 - 3, Retrieved from the Internet <URL:《https://blog.csdn.net/weixin_45951701/article/details/117486242》> *
丁一等: "《用户中心设计导论》", 30 November 2020, 中国纺织出版社, pages: 71 - 74 *
李本乾等: "《人工智能时代新型媒介、产业与社会》", 30 November 2021, 上海交通大学出版社, pages: 6 - 15 *

Similar Documents

Publication Publication Date Title
CN106528389B (en) Performance evaluation method and device for system fluency and terminal
CN111221733B (en) Information processing method, device, mobile terminal and storage medium
CN105303371A (en) Bill processing method and device and terminal device
CN107316207B (en) Method and device for acquiring display effect information
CN110266914B (en) Image shooting method, device and computer readable storage medium
CN104932970A (en) Monitoring method and device of memory leakage
EP3068097A1 (en) Method and device for filtering information
US11050878B1 (en) Methods, systems and computer program products for detecting anomalies in a telecommunications network
CN114546541A (en) Method and system for accurately acquiring screen service time of Android device
EP3494787B1 (en) Method and device for replacing insecticide component
CN110968492A (en) Information processing method and device, and storage medium
CN114547073A (en) Aggregation query method and device for time series data and storage medium
CN115563156A (en) Method, device and equipment for checking stream data information and storage medium
CN108231037B (en) Method and device for determining screen brightness setting range
CN109511114B (en) Method and device for configuring seed IMSI/Ki associated key
CN112819061A (en) Password information identification method, device, equipment and storage medium
CN113946353B (en) Data processing method and device, electronic equipment and storage medium
CN112883314A (en) Request processing method and device
CN111597106A (en) Point burying management method and device
CN112311770A (en) Information platform selection method and device, electronic equipment and storage medium
CN110968516A (en) Application memory testing method and device and computer storage medium
EP4114058A1 (en) Method and device for realizing signaling detection, user equipment, and base station
CN114900233B (en) Method and device for renovating and managing optical network unit, electronic equipment and medium
CN110581925A (en) Method and system for adjusting parameters of predictive outbound algorithm, electronic equipment and storage medium
CN112162918B (en) Application program testing method and device and electronic equipment

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination