Java Code Examples for android.view.WindowManager#InvalidDisplayException

The following examples show how to use android.view.WindowManager#InvalidDisplayException . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DisplayManager.java    From libvlc-sdk-android with GNU General Public License v2.0 6 votes vote down vote up
private SecondaryDisplay createPresentation() {
    if (mMediaRouter == null) return null;
    final MediaRouter.RouteInfo route = mMediaRouter.getSelectedRoute(MediaRouter.ROUTE_TYPE_LIVE_VIDEO);
    final Display presentationDisplay = route != null ? route.getPresentationDisplay() : null;
    if (presentationDisplay != null) {
        if (BuildConfig.DEBUG)
            Log.i(TAG, "Showing presentation on display: " + presentationDisplay);
        final SecondaryDisplay presentation = new SecondaryDisplay(mActivity, presentationDisplay);
        presentation.setOnDismissListener(mOnDismissListener);
        try {
            presentation.show();
            mPresentationId = presentationDisplay.getDisplayId();
            return presentation;
        } catch (WindowManager.InvalidDisplayException ex) {
            if (BuildConfig.DEBUG)
                Log.w(TAG, "Couldn't show presentation!  Display was removed in " + "the meantime.", ex);
            mPresentationId = -1;
        }
    } else if (BuildConfig.DEBUG) Log.i(TAG, "No secondary display detected");
    return null;
}
 
Example 2
Source File: LocalPlayer.java    From media-samples with Apache License 2.0 5 votes vote down vote up
@Override
public void updatePresentation() {
    // Get the current route and its presentation display.
    Display presentationDisplay = mRoute != null ? mRoute.getPresentationDisplay() : null;

    // Dismiss the current presentation if the display has changed.
    if (mPresentation != null && mPresentation.getDisplay() != presentationDisplay) {
        Log.i(TAG, "Dismissing presentation because the current route no longer "
                + "has a presentation display.");
        mPresentation.dismiss();
        mPresentation = null;
    }

    // Show a new presentation if needed.
    if (mPresentation == null && presentationDisplay != null) {
        Log.i(TAG, "Showing presentation on display: " + presentationDisplay);
        mPresentation = new DemoPresentation(getContext(), presentationDisplay);
        mPresentation.setOnDismissListener(mOnDismissListener);
        try {
            mPresentation.show();
        } catch (WindowManager.InvalidDisplayException ex) {
            Log.w(TAG, "Couldn't show presentation!  Display was removed in "
                      + "the meantime.", ex);
            mPresentation = null;
        }
    }

    updateContents();
}
 
Example 3
Source File: VideoPlayerActivity.java    From VCL-Android with Apache License 2.0 5 votes vote down vote up
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
private void createPresentation() {
    if (mMediaRouter == null || mEnableCloneMode)
        return;

    // Get the current route and its presentation display.
    MediaRouter.RouteInfo route = mMediaRouter.getSelectedRoute(
        MediaRouter.ROUTE_TYPE_LIVE_VIDEO);

    Display presentationDisplay = route != null ? route.getPresentationDisplay() : null;

    if (presentationDisplay != null) {
        // Show a new presentation if possible.
        Log.i(TAG, "Showing presentation on display: " + presentationDisplay);
        mPresentation = new SecondaryDisplay(this, LibVLC(), presentationDisplay);
        mPresentation.setOnDismissListener(mOnDismissListener);
        try {
            mPresentation.show();
            mPresentationDisplayId = presentationDisplay.getDisplayId();
        } catch (WindowManager.InvalidDisplayException ex) {
            Log.w(TAG, "Couldn't show presentation!  Display was removed in "
                    + "the meantime.", ex);
            mPresentation = null;
        }
    } else
        Log.i(TAG, "No secondary display detected");
}
 
Example 4
Source File: LocalPlayer.java    From android-MediaRouter with Apache License 2.0 5 votes vote down vote up
@Override
public void updatePresentation() {
    // Get the current route and its presentation display.
    Display presentationDisplay = mRoute != null ? mRoute.getPresentationDisplay() : null;

    // Dismiss the current presentation if the display has changed.
    if (mPresentation != null && mPresentation.getDisplay() != presentationDisplay) {
        Log.i(TAG, "Dismissing presentation because the current route no longer "
                + "has a presentation display.");
        mPresentation.dismiss();
        mPresentation = null;
    }

    // Show a new presentation if needed.
    if (mPresentation == null && presentationDisplay != null) {
        Log.i(TAG, "Showing presentation on display: " + presentationDisplay);
        mPresentation = new DemoPresentation(getContext(), presentationDisplay);
        mPresentation.setOnDismissListener(mOnDismissListener);
        try {
            mPresentation.show();
        } catch (WindowManager.InvalidDisplayException ex) {
            Log.w(TAG, "Couldn't show presentation!  Display was removed in "
                      + "the meantime.", ex);
            mPresentation = null;
        }
    }

    updateContents();
}
 
Example 5
Source File: LocalPlayer.java    From V.FlyoutTest with MIT License 5 votes vote down vote up
@Override
public void updatePresentation() {
    // Get the current route and its presentation display.
    Display presentationDisplay = mRoute != null ? mRoute.getPresentationDisplay() : null;

    // Dismiss the current presentation if the display has changed.
    if (mPresentation != null && mPresentation.getDisplay() != presentationDisplay) {
        Log.i(TAG, "Dismissing presentation because the current route no longer "
                + "has a presentation display.");
        mPresentation.dismiss();
        mPresentation = null;
    }

    // Show a new presentation if needed.
    if (mPresentation == null && presentationDisplay != null) {
        Log.i(TAG, "Showing presentation on display: " + presentationDisplay);
        mPresentation = new DemoPresentation(getContext(), presentationDisplay);
        mPresentation.setOnDismissListener(mOnDismissListener);
        try {
            mPresentation.show();
        } catch (WindowManager.InvalidDisplayException ex) {
            Log.w(TAG, "Couldn't show presentation!  Display was removed in "
                      + "the meantime.", ex);
            mPresentation = null;
        }
    }

    updateContents();
}
 
Example 6
Source File: MainActivity.java    From media-samples with Apache License 2.0 4 votes vote down vote up
/**
 * Updates the displayed presentation to enable a secondary screen if it has
 * been selected in the {@link android.media.MediaRouter} for the
 * {@link android.media.MediaRouter#ROUTE_TYPE_LIVE_VIDEO} type. If no screen has been
 * selected by the {@link android.media.MediaRouter}, the current screen is disabled.
 * Otherwise a new {@link SamplePresentation} is initialized and shown on
 * the secondary screen.
 */
private void updatePresentation() {

    // BEGIN_INCLUDE(updatePresentationInit)
    // Get the selected route for live video
    MediaRouter.RouteInfo selectedRoute = mMediaRouter.getSelectedRoute();

    // Get its Display if a valid route has been selected
    Display selectedDisplay = selectedRoute.getPresentationDisplay();
    // END_INCLUDE(updatePresentationInit)

    // BEGIN_INCLUDE(updatePresentationDismiss)
    /*
     * Dismiss the current presentation if the display has changed or no new
     * route has been selected
     */
    if (mPresentation != null && mPresentation.getDisplay() != selectedDisplay) {
        mPresentation.dismiss();
        mPresentation = null;
        mButton.setEnabled(false);
        mTextStatus.setText(R.string.secondary_notconnected);
    }
    // END_INCLUDE(updatePresentationDismiss)

    // BEGIN_INCLUDE(updatePresentationNew)
    /*
     * Show a new presentation if the previous one has been dismissed and a
     * route has been selected.
     */
    if (mPresentation == null && selectedDisplay != null) {

        // Initialise a new Presentation for the Display
        mPresentation = new SamplePresentation(this, selectedDisplay);
        mPresentation.setOnDismissListener(mOnDismissListener);

        // Try to show the presentation, this might fail if the display has
        // gone away in the mean time
        try {
            mPresentation.show();
            mTextStatus.setText(getResources().getString(R.string.secondary_connected,
                    selectedRoute.getName()));
            mButton.setEnabled(true);
            showNextColor();
        } catch (WindowManager.InvalidDisplayException ex) {
            // Couldn't show presentation - display was already removed
            mPresentation = null;
        }
    }
    // END_INCLUDE(updatePresentationNew)

}
 
Example 7
Source File: MainActivity.java    From android-BasicMediaRouter with Apache License 2.0 4 votes vote down vote up
/**
 * Updates the displayed presentation to enable a secondary screen if it has
 * been selected in the {@link android.media.MediaRouter} for the
 * {@link android.media.MediaRouter#ROUTE_TYPE_LIVE_VIDEO} type. If no screen has been
 * selected by the {@link android.media.MediaRouter}, the current screen is disabled.
 * Otherwise a new {@link SamplePresentation} is initialized and shown on
 * the secondary screen.
 */
private void updatePresentation() {

    // BEGIN_INCLUDE(updatePresentationInit)
    // Get the selected route for live video
    RouteInfo selectedRoute = mMediaRouter.getSelectedRoute(
            MediaRouter.ROUTE_TYPE_LIVE_VIDEO);

    // Get its Display if a valid route has been selected
    Display selectedDisplay = null;
    if (selectedRoute != null) {
        selectedDisplay = selectedRoute.getPresentationDisplay();
    }
    // END_INCLUDE(updatePresentationInit)

    // BEGIN_INCLUDE(updatePresentationDismiss)
    /*
     * Dismiss the current presentation if the display has changed or no new
     * route has been selected
     */
    if (mPresentation != null && mPresentation.getDisplay() != selectedDisplay) {
        mPresentation.dismiss();
        mPresentation = null;
        mButton.setEnabled(false);
        mTextStatus.setText(R.string.secondary_notconnected);
    }
    // END_INCLUDE(updatePresentationDismiss)

    // BEGIN_INCLUDE(updatePresentationNew)
    /*
     * Show a new presentation if the previous one has been dismissed and a
     * route has been selected.
     */
    if (mPresentation == null && selectedDisplay != null) {

        // Initialise a new Presentation for the Display
        mPresentation = new SamplePresentation(this, selectedDisplay);
        mPresentation.setOnDismissListener(mOnDismissListener);

        // Try to show the presentation, this might fail if the display has
        // gone away in the mean time
        try {
            mPresentation.show();
            mTextStatus.setText(getResources().getString(R.string.secondary_connected,
                    selectedRoute.getName(MainActivity.this)));
            mButton.setEnabled(true);
            showNextColor();
        } catch (WindowManager.InvalidDisplayException ex) {
            // Couldn't show presentation - display was already removed
            mPresentation = null;
        }
    }
    // END_INCLUDE(updatePresentationNew)

}