US-12619392-B2 - Display method and electronic device
Abstract
This application provides a display method and an electronic device. The method is applied to a first electronic device, and the method may include: The first electronic device detects a first operation of starting a first application. The first electronic device matches a window of the first application; and when the first electronic device determines that the matched window of the first application is located in the first electronic device, migrates the window of the first application to a second electronic device for display. The technical solutions can be applied to projection technologies. When an application is switched from the first electronic device to the second electronic device for display, data and a status of the application can be retained to avoid restarting the application.
Inventors
- Bo Wang
- Qianqiao Hu
Assignees
- HUAWEI TECHNOLOGIES CO., LTD.
Dates
- Publication Date
- 20260505
- Application Date
- 20220330
- Priority Date
- 20210519
Claims (16)
- 1 . A display method performed by a first electronic device, the method comprising: detecting, by the first electronic device, a first operation associated with starting a first application; matching, by the first electronic device, a window of the first application in windows of applications that have been started; and when the first electronic device determines that the matched window of the first application is located in the first electronic device, migrating the window and associated content of the first application to a second electronic device for display at the second electronic device and retaining a status of the first application at the first electronic device, wherein migrating the window of the first application to a second electronic device for display comprises: migrating, by the first electronic device, content in a first activity stack corresponding to the window of the first application to a second activity stack, wherein the second activity stack is newly created by the first electronic device and serves the second electronic device; and sending, by the first electronic device, data of a window corresponding to the second activity stack to the second electronic device; setting, by the first electronic device, pixels per inch of a screen of the second electronic device to be the same as pixels per inch of a screen of the first electronic device.
- 2 . The display method according to claim 1 , wherein the matching, by the first electronic device, a window of the first application comprises: matching, by the first electronic device based on first information, the window of the first application from windows of applications that have been started in the first electronic device.
- 3 . The display method according to claim 2 , wherein the first information comprises at least one of the following items taken singularly or in any combination with one another: a package name of the started application, a user identity of the started application, or an activity corresponding to the started application.
- 4 . The display method according to claim 1 , wherein a window of the first application displayed on the second electronic device further comprises a title bar that includes a name of the first application.
- 5 . The display method according to claim 1 , wherein a size of the window of the first application displayed on the second electronic device is different from a size of the window of the first application displayed on the first electronic device.
- 6 . The display method according to claim 1 , wherein the size of the window of the first application displayed on the second electronic device is adjustable.
- 7 . The display method according to claim 1 , further comprising: when the first electronic device determines that the matched window of the first application is located in the second electronic device, placing the window of the first application on a foreground of the second electronic device for display.
- 8 . The display method according to claim 1 , further comprising: detecting, by the first electronic device, a state change of the second electronic device; and intercepting, by the first electronic device, a message that is used for interface relaunching and that is sent by the first electronic device to the first application based on the state change.
- 9 . The display method according to claim 1 , wherein the first operation is triggered on the first electronic device or on the second electronic device.
- 10 . A first electronic device, comprising: at least one processor; and a memory coupled to the at least one processor and configured to store programming instructions that, when executed by the at least one processor, cause the first electronic device to perform operations comprising: detecting a first operation associated with starting a first application; matching a window of the first application in windows of applications that have been started; and when the first electronic device determines that the matched window of the first application is located in the first electronic device, migrating the window and associated content of the first application to a second electronic device for display at the second electronic device and retaining a status of the first application at the first electronic device, wherein migrating the window of the first application to a second electronic device for display comprises: migrating, by the first electronic device, content in a first activity stack corresponding to the window of the first application to a second activity stack, wherein the second activity stack is newly created by the first electronic device and serves the second electronic device; and sending, by the first electronic device, data of a window corresponding to the second activity stack to the second electronic device; and setting, by the first electronic device, pixels per inch of a screen of the second electronic device to be the same as pixels per inch of a screen of the first electronic device.
- 11 . The first electronic device according to claim 10 , wherein the matching a window of the first application comprises: matching, based on first information, the window of the first application from windows of applications that have been started in the first electronic device.
- 12 . The first electronic device according to claim 11 , wherein the first information comprises at least one of the following items taken singularly or in any combination with one another: a package name of the started application, a user identity of the started application, and an activity corresponding to the started application.
- 13 . The first electronic device according to claim 10 , wherein a window of the first application displayed on the second electronic device further comprises a title bar that includes a name of the first application.
- 14 . The first electronic device according to claim 10 , wherein a size of the window of the first application displayed on the second electronic device is different from a size of the window of the first application displayed on the first electronic device.
- 15 . The first electronic device according to claim 10 , wherein the size of the window of the first application displayed on the second electronic device is adjustable.
- 16 . The first electronic device according to claim 10 , wherein the operations further comprise: when the first electronic device determines that the matched window of the first application is located in the second electronic device, placing the window of the first application on a foreground of the second electronic device for display.
Description
CROSS-REFERENCE TO RELATED APPLICATIONS This application is a National Stage of International Application No. PCT/CN2022/083911 filed on Mar. 30, 2022, which claims priority to Chinese Patent Application No. 202110550254.0 filed on May 19, 2021 and claims priority to Chinese Patent Application No. 202110930452.X filed on Aug. 13, 2021. All of the aforementioned patent applications are hereby incorporated by reference in their entireties. TECHNICAL FIELD This application relates to the field of electronic technologies, and more specifically, to a display method and an electronic device. BACKGROUND In a projection scenario, for example, a first electronic device is projected to a second electronic device. To be specific, content of a screen of the first electronic device needs to be displayed on a screen of the second electronic device. When an application is switched from the screen of the first electronic device to the screen of the second electronic device for display, the first electronic device usually restarts the application and then displays the restarted application on the screen of the second electronic device, resulting in a data loss of the application. For example, the application is HUAWEI Video. When the first electronic device starts HUAWEI Video to play a video, and in this case, HUAWEI Video is switched to the screen of the second electronic device for display, HUAWEI Video needs to be started again, and the video that is originally being played on the first electronic device cannot continue to be played on the second electronic device. SUMMARY This application provides a display method and an electronic device. In this technical solution, when an application is switched from an electronic device to another electronic device for display, a status of the application can be retained to avoid restarting the application. According to a first aspect, a display method is provided. The method is applied to an electronic device, and the method includes: A first electronic device detects a first operation of starting a first application. The first electronic device matches a window of the first application: and when the first electronic device determines that the matched window of the first application is located in the first electronic device, migrates the window of the first application to a second electronic device for display. In an embodiment of this application, after detecting an operation of starting a first application, a first electronic device matches a window of the first application in windows of applications that have been started. When determining that the matched window of the first application is in the first electronic device, the window of the first application is migrated to a second electronic device for display. In this technical solution, when an application is switched from a first electronic device to a second electronic device for display, data and a status of the application can be retained to avoid restarting the application. With reference to the first aspect, in some implementations of the first aspect, the migrating the window of the first application to the second electronic device for display includes: The first electronic device migrates content in a first activity stack corresponding to the window of the first application to a second activity stack. The first electronic device sends data of a window corresponding to the second activity stack to the second electronic device. It should be understood that the second activity stack may be newly created by the first electronic device, and the second activity stack serves the second electronic device, so that a plurality of electronic devices can be managed by stack, thereby avoiding a restarting phenomenon that occurs when an application is switched from an electronic device to another electronic device for display. In an embodiment of this application, the first electronic device migrates the content in the first activity stack corresponding to the window of the first application to the second activity stack, so that a task and an activity record in the first activity stack can be retained, that is, data of the first application can be stored. In this way: when the first application is switched to the second electronic device for display, the data of the first application is not lost, thereby improving application continuity. Optionally: the method may further include: The first electronic device removes the first activity stack. Therefore, system power consumption of the electronic device can be reduced. With reference to the first aspect, in some implementations of the first aspect, that the first electronic device matches a window of the first application includes: The first electronic device matches, based on first information, the window of the first application from windows of applications that have been started in the first electronic device. In this technical solution, it may be determined whether the window of