This application provides a screen mirroring method and an electronic device. The method involves determining whether a screen mirroring intention exists in the environment; when a screen mirroring intention exists and the
Digital Living Network Alliance (DLNA) function of a second device in the environment is disabled, a first enable instruction is sent to the second device, instructing the second device to enable the DLNA function; in response to receiving a first event from a first device, a second enable instruction is sent to the second device, the first event indicating that the first device has a screen mirroring intention, and the second enable instruction instructing the second device to send
multicast, which is used by the first device to discover the second device for screen mirroring. This application allows for
adaptive control of the second device enabling the DLNA function and sending
multicast, reducing the bandwidth occupied by
multicast.