I'm developing an Android app (using Java and Groovy) and want to add built‑in screen mirroring/casting functionality using Miracast. My goal is to mirror the phone screen to a TV directly within my app—without redirecting the user to the device’s cast settings or developing a separate TV receiver app.
What I’ve Tried:
WebRTC: Discarded because my TV lacks internal WebRTC support.
ConnectSDK: Encountered build errors (e.g., mergeDebugResources/mergeDuplicatedClasses errors related to an “Unrecognized ':' sign” in values.xml).
Direct RTP/UDP Packet Transmission: I built RTP/UDP packets using Java (with some help from AI), and LogCat shows transmission to the TV, but no display changes occur. (I can share my code on request.)
Internal/Native Android APIs: Attempted using Wi‑Fi Display APIs, but only the WFD Info class is accessible.
Converting Screen Recordings to MPEG-2 TS with PES Packets: Similar approach as RTP/UDP resulted in no visible change on the TV.
Desired Workflow:
- User taps a button in my app.
- The app discovers available TVs via Wi‑Fi Direct and displays them in an in‑app dialog.
- The user selects a TV.
- The app automatically initiates the Miracast connection in the background—without launching or requiring any further interaction with the system’s cast settings UI.
My Question:
Is it possible to fully manage a Miracast (Wi‑Fi Direct) connection entirely within my app (i.e., automatically or in a background thread) without having to open the system cast settings? If so, are there any Java libraries, APIs, or SDKs that support this functionality across a wide range of devices without compromising warranty or limiting device compatibility?
Any advice or pointers toward a solution would be greatly appreciated. (My TV Model No: UE43DU7000XTK)