CN113535293B - Android device screen capturing method, system and medium - Google Patents

Android device screen capturing method, system and medium Download PDF

Info

Publication number
CN113535293B
CN113535293B CN202110609604.6A CN202110609604A CN113535293B CN 113535293 B CN113535293 B CN 113535293B CN 202110609604 A CN202110609604 A CN 202110609604A CN 113535293 B CN113535293 B CN 113535293B
Authority
CN
China
Prior art keywords
image
class
screenshot
acquiring
program
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.)
Active
Application number
CN202110609604.6A
Other languages
Chinese (zh)
Other versions
CN113535293A (en
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.)
Inspur Financial Information Technology Co Ltd
Original Assignee
Inspur Financial Information Technology Co 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 Inspur Financial Information Technology Co Ltd filed Critical Inspur Financial Information Technology Co Ltd
Priority to CN202110609604.6A priority Critical patent/CN113535293B/en
Publication of CN113535293A publication Critical patent/CN113535293A/en
Application granted granted Critical
Publication of CN113535293B publication Critical patent/CN113535293B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

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/451Execution arrangements for user interfaces
    • 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/448Execution paradigms, e.g. implementations of programming paradigms
    • G06F9/4488Object-oriented

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)
  • Two-Way Televisions, Distribution Of Moving Picture Or The Like (AREA)
  • User Interface Of Digital Computer (AREA)

Abstract

The invention discloses a method, a system and a medium for screen capturing of android equipment, wherein the method comprises the following steps: calling a system interface manager through the running environment class of the system program; acquiring the intention class of the system program through a system interface manager, sending a corresponding request to the system according to the intention class, and responding the request and generating response data by the system; creating a screenshot reading class object of the system program, acquiring a screenshot image through response data, a system interface manager and the screenshot reading class object, and setting parameters of the screenshot image; projecting the screenshot image onto a screenshot reading canvas to perform image rendering to obtain an image frame queue; acquiring a first image in an image frame queue through an image acquisition class of a system program; acquiring a required format of the first image, and converting the format of the first image according to the required format; through the mode, the problems of different modes of screen capturing on different mainboards can be reduced, and the development difficulty of the screen capturing technology is reduced.

Description

Android device screen capturing method, system and medium
Technical Field
The invention relates to the field of android device screen capturing, in particular to a method, a system and a medium for android device screen capturing.
Background
Screen capturing technologies on the development level of the android system are roughly divided into two categories:
the prior art is as follows: obtaining view cache data of view layout at the topmost layer of a user interface window, converting the view cache data, and then generating an interface screenshot of the android device;
the first disadvantage of the prior art is that the interface activity of the user is highly dependent, and images of special positions such as a status bar, a navigation bar and the like cannot be intercepted during screenshot;
the prior art is as follows: obtaining screenshot of an equipment interface according to equipment interface screenshot interfaces customized by different mainboard manufacturers;
a further disadvantage of the second prior art is that it is highly dependent on the motherboard screen capture interface provided by the manufacturer, and there may be problems of different implementation manners of screen capture and incompatibility with the own requirements.
Disclosure of Invention
The invention mainly solves the problems that the realization modes of screen capturing on different mainboards are different and great difficulty is brought to the development of screen capturing technology.
In order to solve the technical problems, the invention adopts a technical scheme that: the method for capturing the screen of the android device comprises the following steps:
calling a system interface manager through the running environment class of the system program;
acquiring an intention class of the system program through the system interface manager, and sending a corresponding request to a system according to the intention class, wherein the system responds to the request and generates response data;
creating an object of a screenshot reading class of the system program, acquiring a screenshot image through the response data, the system interface manager and the object of the screenshot reading class, and setting parameters of the screenshot image;
projecting the screenshot images with the parameters set to the canvas of the screenshot reading class for image rendering to obtain an image frame queue;
acquiring a first image in the image frame queue through an image acquisition class of the system program;
and acquiring a required format of the first image, and converting the format of the first image according to the required format.
Preferably, the step of sending the corresponding request to the system according to the intention class further comprises:
the intention class invokes a screen capture program of the system;
and sending an intention request to the system according to the screen capturing program.
Preferably, the step of the system responding to the request and generating response data further comprises:
the system receives the intention request;
responding to the intent request by executing a callback program;
and generating the response data after the callback program is executed.
Preferably, creating an object of a screenshot reading class of the system program, and acquiring a screenshot image through the response data, the system interface manager, and the object of the screenshot reading class further includes:
transmitting the response data to the system interface manager;
the system interface manager obtains the object of the interface data class of the system program according to the response data;
creating an object of the screenshot reading class;
and the object of the screenshot reading class cooperates with the object of the interface data class to acquire the screenshot image.
Preferably, the step of setting parameters of the screen capturing image further includes:
acquiring parameter requirements of the screen capturing image;
accessing image data of the screenshot image through the screenshot reading class object;
and setting parameters of the screen capturing image according to the parameter requirements of the screen capturing image and the image data of the screen capturing image.
Preferably, the parameters of the screen capturing image include: image size, image format, and maximum number of caches for images.
Preferably, the step of projecting the screenshot image with the parameters set to the canvas of the screenshot reading class for image rendering further includes:
creating a virtual object through the interface data class, and transmitting the canvas into the virtual object;
initializing the virtual display object;
projecting the screen capturing image to the canvas through the initialized virtual display object for rendering;
and rendering the screen capturing image on the canvas to obtain an image frame queue of the screen capturing image.
Preferably, the step of acquiring the first image in the image frame queue by the image acquisition class of the system program further includes:
acquiring the first image in the image frame queue on the canvas through the image acquisition class;
and closing other images in the image frame queues except the first image.
The invention also provides a system for capturing the screen of the android device, which comprises: the system comprises a calling module, a response request module, an image acquisition setting module, a projection rendering module, a first image acquisition module and an image format conversion module;
the calling module is used for calling the system interface manager through the running environment class of the system program;
the response request module is used for acquiring the intention class of the system program through the system interface manager;
the response request module is also used for sending a corresponding request to the system according to the intention class and generating response data;
the image acquisition setting module is used for creating an object of a screenshot reading class of the system program, acquiring a screenshot image through the response data, the system interface manager and the object of the screenshot reading class, and setting parameters of the screenshot image;
the projection rendering module is used for projecting the screenshot images with the parameters set to the canvas of the screenshot reading class for image rendering to obtain an image frame queue;
the first image acquisition module is used for acquiring a first image in the image frame queue through an image acquisition class of the system program;
the image format conversion module is used for acquiring a required format of the first image and converting the format of the first image according to the required format.
The invention also provides a computer readable storage medium storing a computer program which, when executed by a processor, implements the method steps of the android device screen capturing.
The beneficial effects of the invention are as follows:
1. the method for capturing the screen of the android device can reduce the limitation of different implementation modes of the screen capturing caused by high customization due to open source of android system codes;
2. the system for capturing the screen of the android device can realize the enhancement of the universality of the screen capturing modes on the intelligent android devices of different manufacturers and can be used in various scenes;
3. the android device screen capturing medium can reduce the dependence on a screen capturing interface provided by a manufacturer mainboard and can ensure the integrity of captured images.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings that are needed in the description of the embodiments or the prior art will be briefly described, and it is obvious that the drawings in the description below are some embodiments of the present invention, and other drawings can be obtained according to the drawings without inventive effort for a person skilled in the art.
Fig. 1 is a flowchart of a method for capturing a screen of an android device according to embodiment 1 of the present invention;
fig. 2 is a schematic diagram of a system architecture of an android device screen capture according to embodiment 2 of the present invention.
Detailed Description
The following description of the embodiments of the present invention will be made apparent and fully in view of the accompanying drawings, in which some, but not all embodiments of the invention are shown. All other embodiments, which can be made by those skilled in the art based on the embodiments of the invention without making any inventive effort, are intended to be within the scope of the invention.
In the description of the present invention, it is to be noted that:
WFD is a water frame instruction;
the API is an application programming interface;
the virtual display is a virtual display, which is called virtual display for short;
the running environment corresponds to Context;
the intention class corresponds to the intent class;
the system interface manager corresponds to a MediaProjectionManager;
the interface data class corresponds to a mediaproject class;
the screenshot reading class corresponds to an ImageReader class;
the image acquisition class corresponds to an acquiratestimage class;
a method, a system and a medium for screen capturing of android equipment are mainly applicable to android intelligent terminal equipment of an android system 6.0 and above.
Example 1
The embodiment of the invention provides a method for capturing a screen of android equipment, referring to fig. 1, comprising the following steps:
s100, calling a mediaProjectionmanager to perform screenshot service through a Context of an android system screenshot program;
the Context, namely the running environment, can be understood as a bridge, and the Context provides a method for calling system resources; the Context exists in a related program of the Activity class in the code for performing android device screen capturing;
the mediaproject manager is used for managing mediaproject screen capturing programs, and the mediaproject manager provides system-level services for calling bottom-layer interfaces such as screen capturing or screen recording;
mediaproject is a class in android system screen capturing program, and is used for acquiring content data on a screen or recording interface data of a system, and the screen content data and the system interface data can be output through the mediaproject class;
the class is defined rules or functions in advance, the object in the class created by the user is an entity, and the rules or functions are realized through the object;
s200, acquiring an Intent class, sending an Intent request to a system, acquiring a system response and generating response data;
s201, acquiring an Intent class by using a MediaProjectionManager, and calling a screen capture program in an android system through the acquired Intent class to send a screen capture Intent request to the android system;
the Intent class can start Activity, service and broadcast Broadcasts, the Chinese meaning 'intention, intention' of the Intent, and the Intent class is used for providing information for corresponding functions;
s202, after receiving an Intnt request, the system responds to the Intnt request by executing a callback program and acquires Intnt data obtained by executing the callback program;
a system callback, as referred to herein, refers to the execution of a callback function by the system, which may be user written, but must be called by the system;
s300, acquiring a mediaproject object, creating an ImageReader object and setting image parameters;
s301, transmitting the acquired Intent data to a MediaProjectionManager, and enabling the MediaProjectionManager to acquire an object in a MediaProjectionclass according to the acquired data;
the approximate pseudocode is: mediaproject = mediaproject manager (intelt);
s302, creating an object to be processed in an ImageReader class in an android system code, marking the object as a first object, and directly accessing image data of a screen page of the android device through the first object, wherein the data comprises related data of a Surface class for screen rendering, and the image data is directly accessed and used for intercepting an image of the screen page of the android device in cooperation with a MediaProjection class;
parameters set for the images include the size, format and maximum buffer number maxImages of the incoming images, and when the image parameters are set, the maximum buffer number maxImages of the images is set to be at least 2, so that the situation that the image data cannot lose frames can be ensured;
s400, creating a virtual display object, namely a virtual display object, through a mediaproject class, and transmitting the Surface into the virtual display object; after the virtual display object is initialized, the interface image intercepted on the android device can be projected on a Surface for image rendering, and 100ms time is recommended to be used for image rendering, so that an image frame queue of the screenshot is obtained, namely the Surface is equivalent to holding data of each frame of image on the screen;
the virtual display has a plurality of use scenes, such as screen recording, WFD display and the like, and has the function of capturing the content displayed on the screen; the virtual display captures the screen content, the implementation mode is quite large, and an image reader is provided in an API to read the content in the virtual display;
in an android system, views and subclasses thereof are drawn on surfaces, and each page window corresponds to one surface;
s500, acquiring the latest frame of image from an image frame queue of an image reader class through a function in the acquiratest image class, marking the latest frame of image as a first image, and closing other images except the latest frame of image;
s600, converting the first image into an image format meeting the functional requirement according to the service requirement, generally converting the first data into a Bitmap data format, wherein the Bitmap refers to a Bitmap, and the Bitmap is an image represented by using a pixel array.
Example 2
The embodiment of the invention also provides a system for capturing a screen of the android device, referring to fig. 2, including: the system comprises a calling module, a response request module, an image acquisition setting module, a projection rendering module, a first image acquisition module and an image format conversion module;
the calling module is used for calling the system interface manager through the running environment class of the system program;
the response request module is used for acquiring the intention class of the system program through the system interface manager;
the response request module is also used for sending a corresponding request to the system according to the intention class and generating response data;
the image acquisition setting module is used for creating an object of a screenshot reading class of the system program, acquiring a screenshot image through response data, a system interface manager and the object of the screenshot reading class, and setting parameters of the screenshot image;
the projection rendering module is used for projecting the screen capturing images with the set parameters onto a canvas of a screen capturing reading class for image rendering to obtain an image frame queue;
the first image acquisition module is used for acquiring a first image in the image frame queue through an image acquisition class of the system program;
the image format conversion module is used for acquiring a required format of the first image and converting the format of the first image according to the required format.
Example 3
The present invention also provides a computer readable storage medium storing a computer program which when executed by a processor performs the method as above;
it should be noted that, those skilled in the art may understand that all or part of the processes in the methods of the embodiments may be implemented by a computer program to instruct related hardware, and the program may include the processes of the embodiments of the methods as described above when executed. The storage medium of the program may be a magnetic disk, an optical disk, a read-only memory (ROM), a random-access memory (RAM), or the like. The embodiments of the computer program described above may achieve the same or similar effects as any of the method embodiments described above corresponding thereto;
those of skill would further appreciate that the various illustrative logical blocks, modules, circuits, and algorithm steps described in connection with the disclosure herein may be implemented as electronic hardware, computer software, or combinations of both. To clearly illustrate this interchangeability of hardware and software, various illustrative components, blocks, modules, circuits, and steps have been described above generally in terms of their functionality. Whether such functionality is implemented as software or hardware depends upon the particular application and design constraints imposed on the overall system. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present disclosure.
The foregoing embodiment of the present invention has been disclosed with reference to the number of embodiments for the purpose of description only, and does not represent the advantages or disadvantages of the embodiments.
The foregoing description is only illustrative of the present invention and is not intended to limit the scope of the invention, and all equivalent structures or equivalent processes or direct or indirect application in other related technical fields are included in the scope of the present invention.

Claims (4)

1. A method for capturing a screen of an android device, comprising the following steps:
calling a system interface manager through the running environment class of the system program;
acquiring an intention class of the system program through the system interface manager, and sending a corresponding request to a system according to the intention class, wherein the system responds to the request and generates response data;
creating an object of a screenshot reading class of the system program, acquiring a screenshot image through the response data, the system interface manager and the object of the screenshot reading class, and setting parameters of the screenshot image;
projecting the screenshot images with the parameters set to the canvas of the screenshot reading class for image rendering to obtain an image frame queue;
acquiring a first image in the image frame queue through an image acquisition class of the system program;
acquiring a required format of the first image, and converting the format of the first image according to the required format;
the step of sending a corresponding request to the system according to the intent class further comprises: the intention class invokes a screen capture program of the system; sending an intention request to the system according to the screen capturing program;
the step of the system responding to the request and generating response data further comprises: the system receives the intention request; responding to the intent request by executing a callback program; generating the response data after the callback program is executed;
the step of creating the object of the screenshot reading class of the system program and acquiring the screenshot image through the response data, the system interface manager and the object of the screenshot reading class further comprises: transmitting the response data to the system interface manager; the system interface manager obtains the object of the interface data class of the system program according to the response data; creating an object of the screenshot reading class; the object of the screenshot reading class cooperates with the object of the interface data class to acquire the screenshot image;
the step of setting parameters of the screenshot image further comprises: acquiring parameter requirements of the screen capturing image; accessing image data of the screenshot image through the screenshot reading class object; setting parameters of the screen capturing image according to the parameter requirements of the screen capturing image and the image data of the screen capturing image;
the parameters of the screen capturing image comprise: image size, image format, and maximum number of caches for images;
the step of projecting the screenshot image with the parameters set to the canvas of the screenshot reading class for image rendering further comprises the following steps: creating a virtual object through the interface data class, and transmitting the canvas into the virtual object; initializing the virtual display object; projecting the screen capturing image to the canvas through the initialized virtual display object for rendering; and rendering the screen capturing image on the canvas to obtain an image frame queue of the screen capturing image.
2. The method of android device screen capturing of claim 1, wherein said step of acquiring a first image in said image frame queue via an image acquisition class of said system program further comprises:
acquiring the first image in the image frame queue on the canvas through the image acquisition class;
and closing other images in the image frame queues except the first image.
3. A system for capturing a screen of an android device, using the method for capturing a screen of an android device according to claim 1, wherein the system comprises: the system comprises a calling module, a response request module, an image acquisition setting module, a projection rendering module, a first image acquisition module and an image format conversion module;
the calling module is used for calling the system interface manager through the running environment class of the system program;
the response request module is used for acquiring the intention class of the system program through the system interface manager;
the response request module is also used for sending a corresponding request to the system according to the intention class and generating response data;
the image acquisition setting module is used for creating an object of a screenshot reading class of the system program, acquiring a screenshot image through the response data, the system interface manager and the object of the screenshot reading class, and setting parameters of the screenshot image;
the projection rendering module is used for projecting the screenshot images with the parameters set to the canvas of the screenshot reading class for image rendering to obtain an image frame queue;
the first image acquisition module is used for acquiring a first image in the image frame queue through an image acquisition class of the system program;
the image format conversion module is used for acquiring a required format of the first image and converting the format of the first image according to the required format.
4. A computer readable storage medium storing a computer program, characterized in that the computer program, when executed by a processor, implements the method steps of an android device screen capture of claim 1 or 2.
CN202110609604.6A 2021-06-01 2021-06-01 Android device screen capturing method, system and medium Active CN113535293B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110609604.6A CN113535293B (en) 2021-06-01 2021-06-01 Android device screen capturing method, system and medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110609604.6A CN113535293B (en) 2021-06-01 2021-06-01 Android device screen capturing method, system and medium

Publications (2)

Publication Number Publication Date
CN113535293A CN113535293A (en) 2021-10-22
CN113535293B true CN113535293B (en) 2023-10-03

Family

ID=78094981

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110609604.6A Active CN113535293B (en) 2021-06-01 2021-06-01 Android device screen capturing method, system and medium

Country Status (1)

Country Link
CN (1) CN113535293B (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114579246B (en) * 2022-05-05 2022-07-08 北京麟卓信息科技有限公司 Screen capturing method for android application in multi-window mode in android compatible environment

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107450915A (en) * 2017-07-18 2017-12-08 四川长虹电器股份有限公司 A kind of method of the quick interception long figure of multi-screen
CN108563382A (en) * 2018-02-26 2018-09-21 挖财网络技术有限公司 Screenshotss method and device based on android system
CN111327947A (en) * 2020-02-11 2020-06-23 平安科技(深圳)有限公司 Screen capture management method and device and mobile terminal

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107450915A (en) * 2017-07-18 2017-12-08 四川长虹电器股份有限公司 A kind of method of the quick interception long figure of multi-screen
CN108563382A (en) * 2018-02-26 2018-09-21 挖财网络技术有限公司 Screenshotss method and device based on android system
CN111327947A (en) * 2020-02-11 2020-06-23 平安科技(深圳)有限公司 Screen capture management method and device and mobile terminal

Also Published As

Publication number Publication date
CN113535293A (en) 2021-10-22

Similar Documents

Publication Publication Date Title
CN110177218B (en) Photographing image processing method of android device
US11016641B2 (en) Method and apparatus for taking screenshot of screen of application in mobile terminal
US20040212687A1 (en) System for controlling a camera resource in a portable device
JP2008526143A (en) Method of acquiring video data using a camera-equipped mobile phone as a computer camera
US20170302747A1 (en) Card-type desktop implementation method, apparatus, and system
CN113784049B (en) Camera calling method of android system virtual machine, electronic equipment and storage medium
CN113535293B (en) Android device screen capturing method, system and medium
CN113542757A (en) Image transmission method and device for cloud application, server and storage medium
WO2019047187A1 (en) Navigation bar control method and device
CN111314606A (en) Photographing method and device, electronic equipment and storage medium
CN107295243A (en) The method and mobile terminal of mobile terminal collection image
CN116546228B (en) Plug flow method, device, equipment and storage medium for virtual scene
CN112532785B (en) Image display method, image display device, electronic apparatus, and storage medium
WO2024051824A1 (en) Image processing method, image processing circuit, electronic device, and readable storage medium
CN109656826B (en) Application testing method, system, device and computer readable storage medium
CN114595084A (en) Method for sharing video between system-level processes on Linux operating system
CN111752505A (en) Real-time image capturing method, system and storage medium for VR
CN113347450A (en) Method, device and system for sharing audio and video equipment by multiple applications
CN113687750B (en) Screenshot processing method and device
CN114222185A (en) Video playing method, terminal equipment and storage medium
CN110908660A (en) Two-dimensional code generation method and device, computer equipment and storage medium
CN112367295A (en) Plug-in display method and device, storage medium and electronic equipment
CN111414211A (en) Method, device, equipment and storage medium for displaying image in system starting phase
CN116528043B (en) Object marking method and electronic equipment
WO2024082863A1 (en) Image processing method and electronic device

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
GR01 Patent grant
GR01 Patent grant