/Miracast-Sample

Test application for using Presentation which display something on the remote display like a TV over Miracast technology.

Primary LanguageJava

Miracast Sample

Test application of Android using Presentation class which displays something on the remote display like a TV over Miracast technology.

Demo

Demo image

Install this apk to the Nexus4 and display a simple text "Hello world,…" to the remote display which is connected the Miracast receiver(PTV3000 /firmware 2.2.2).

Digest

How to get displays

DisplayManger handles all displays including the local display.

mDisplayManager = (DisplayManager)getSystemService(Context.DISPLAY_SERVICE);

You can get all displays via DisplayManager.

Display[] displays = mDisplayManager.getDisplays();

Show the remote display

Super easy to show something on the remote display. Just call show() method which is implemented in Presentation class provided by Android SDKr17.

private void showPresentation(Display display) {
    RemotePresentation presentation = new RemotePresentation(this, display);
    presentation.show();
}

RemotePresentation class is extended Presentation. Presentation class looks like Activity. You can set up the display overriding the onCreate method.

private final class RemotePresentation extends Presentation {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.remote_display);
    }
}

This demo apk shows only TextView on the remote display. The layout resource is remote_display.xml.

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity" >

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        android:layout_centerVertical="true"
        android:textSize="22sp"
        android:textStyle="bold"
        android:text="@string/hello_world" />

</RelativeLayout>

How to setup the miracast environment

Test Enviroinment

Nexus4: Currently only Nexus4 supports the Miracast(27 Dec. 2012).

PTV3000: I've tested this apk with PTV3000.

Nexus4

Turn on the "Wireless Display" on the Settings.

Wireless Display

You can find wireless displays and tap an item to connect.

Connecting the wireless display

PTV3000

Check the firmware version. I bought this gadget from Amazon.com and the version is 1.0.13. TOO LOW!! This version does not support Miracast. You need to update the firmware in 2 steps.

STEP1: Download the latest firmware which is on Internet. I could find the version 2.2.2. This might not be official, I guess.

STEP2: Update the firmware. See the Installation Guide (PDF)