I want to develop an AP to share (SOURCE) screen to another (SINK) device by using WiFi direct connection.
I successfully connect two devices via Wifi direct API but getPresentationDisplay()
returns null. It seems SOURCE device does not find any additional display service exported by SINK device. Does API level 4.2.2 support it? Or is any API that I can register the display service to SOURCE?
//Get Media router service
mMediaRouter = (MediaRouter) getSystemService(Context.MEDIA_ROUTER_SERVICE);
MediaRouter.RouteInfo route = mMediaRouter.getSelectedRoute(MediaRouter.ROUTE_TYPE_LIVE_VIDEO);
if (route != null) {
Display presentationDisplay = route.getPresentationDisplay();
if (presentationDisplay != null) {
Presentation presentation = new DemoPresentation(this, presentationDisplay);
Log.i("tracer", "presentation.show();");
presentation.show();
}
}
On your Android phone, Navigate to Settings. Select the bottom right hand menu and tap Wi-Fi Direct. Your TV should appear in the list. Tap on the Smart TV listed and press Accept to connect to it.
Send files with Wi-Fi Direct: Open Files, touch and hold a file you want to send, and go to More > Share > Wi-Fi Direct. When another device is detected, touch its name to establish the connection and begin file transfer.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With