15

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();
    }
}
Angew is no longer proud of SO
  • 167,307
  • 17
  • 350
  • 455
user2512862
  • 151
  • 1
  • 5

2 Answers2

1

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

Ales Teska
  • 1,198
  • 1
  • 17
  • 38
0

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

  • Note that [link-only answers](http://meta.stackoverflow.com/tags/link-only-answers/info) are discouraged, SO answers should be the end-point of a search for a solution (vs. yet another stopover of references, which tend to get stale over time). Please consider adding a stand-alone synopsis here, keeping the link as a reference. – kleopatra Dec 09 '13 at 10:36
  • 1
    @kleopatra This is not a link-only answer. I have given an explanation as to what didn't work for me, and why it didn't. The link contains several steps and source patches that cannot be replicated here. Hence the "refer to" – Manish Narang Dec 09 '13 at 12:16