How can I share screen to another device base on WiFi direct connection
I'm author if CatVision.io - an screen share software component for Android applications. The source code relevant to a media projection (basically a screen of the device) is here: https://github.com/TeskaLabs/CatVision-io-SDK-Android/blob/master/cvio/src/main/java/com/teskalabs/cvio/CatVision.java
It depends on the device that you are trying to connect to. Android by default does not act as a Miracast/ Wireless Display Sink.
To be able to achieve Android - Android wireless display sharing, refer to Miracast Sink support for android - HowTo