0

JellyBean のプレゼンター機能を使用して、追加の大画面にカスタム グラフィックを表示しようとしています。MHL準拠のHDMIアダプタ(microUSB→HDMI)で接続しています。外部ディスプレイを検出しようとしている私のコードの一部を以下に示します。何らかの理由で、外部モニターに出力が表示されますが、DisplayManager が外部ディスプレイを検出しません。これはアダプターに関係しているのか、それとも HDMI ケーブルで電話を外部ディスプレイに直接接続した場合に当てはまるのでしょうか?

私のログキャット: http://postimg.org/image/sloflge1b/

私のコード部分:

@SuppressLint("NewApi")
private void updatePresentation() {
    // Get the current route and its presentation display.
    Log.d(EXTRA_DISPLAY_TAG, "Inside updatePresentation() call...");

    MediaRouter.RouteInfo route = mediaRouter.getSelectedRoute(MediaRouter.ROUTE_TYPE_LIVE_VIDEO);

    Log.d(EXTRA_DISPLAY_TAG, "Route name: " + route.getName() + " , route status: " + route.getStatus());
    Display externalDisplay = null;
    if(route != null && route.getName().equals("HDMI")){
        externalDisplay = route.getPresentationDisplay();
        if(externalDisplay == null){ //Maybe not ready...
            Log.d(EXTRA_DISPLAY_TAG, "Waiting for external display to become ready...");
            SystemClock.sleep(2000);
            DisplayManager displayManager = (DisplayManager)getSystemService(DISPLAY_SERVICE);
            Display[] presentationDisplays = displayManager.getDisplays(DisplayManager.DISPLAY_CATEGORY_PRESENTATION);
            if(null == presentationDisplays || presentationDisplays.length == 0){
                Log.d(EXTRA_DISPLAY_TAG, "Didn't find any presentation displays by category...");
            }else{
                externalDisplay = presentationDisplays[0]; //OK: Take first
            }
            //Try to manually select display...
            if(externalDisplay == null){
                Display[] allDisplays = displayManager.getDisplays();
                for(int i=0; i<allDisplays.length; i++){
                    Log.d(EXTRA_DISPLAY_TAG, "Detected display  "+(i+1)+ " : " + allDisplays[i].getName());
                }


                //externalDisplay = allDisplays[0]; //FIXME: Take by some criteria...
            }
        }
    }

    if(externalDisplay != null){
        Log.i(EXTRA_DISPLAY_TAG, "Detected external display...");
        Point size = new Point();
        externalDisplay.getSize(size);
        int width = size.x;
        int height = size.y;
        Log.i(EXTRA_DISPLAY_TAG, "External display resolution: " + width + "px x " + height + "px");
    }

    // Dismiss current presentation if display changes
    if(quantumPresentation != null && quantumPresentation.getDisplay() != externalDisplay){

        Log.i(EXTRA_DISPLAY_TAG, "Leaving presentation because current route no longer has a presentation display.");
        quantumPresentation.dismiss();
        quantumPresentation = null;
    }

    // Show new presentation if needed
    if(quantumPresentation == null && externalDisplay != null) {
        Log.i(EXTRA_DISPLAY_TAG, "Showing presentation on display: "  + externalDisplay);
        quantumPresentation = new QuantumPresentation(this, externalDisplay);
        quantumPresentation.setOnDismissListener(onPresentationDismissListener);            
        try{
            Log.i(EXTRA_DISPLAY_TAG, "Starting additional display presentation...");
            quantumPresentation.show();
        } catch (WindowManager.InvalidDisplayException ex){
            Log.w(EXTRA_DISPLAY_TAG, "Couldn't show presentation! External display was removed in the meantime!", ex);
            quantumPresentation = null;
        }

    }
    // Update the contents playing in activity...
    updateContents();


}
4

1 に答える 1

2

報告されているように、Galaxy Nexus は複数の独立したディスプレイをサポートしていません: https://code.google.com/p/android/issues/detail?id=42509

于 2013-05-22T20:46:51.373 に答える