Android Marshmallow双屏(LCD+HDMI)分屏显示实现咨询
实现TI开发板(Android Marshmallow)LCD与HDMI独立显示不同内容的方案
Hey Arun, let's get your setup working so you can play video on LCD and run your custom APK on HDMI. Here's a clear, actionable approach tailored to your TI board running Android Marshmallow:
1. 关闭镜像模式,启用扩展显示
First, you need to break the mirrored display setup. There are two ways to do this:
- UI操作: Go to Settings > Display, look for options like "Display mode" or "Mirror display", and switch it from "Mirror" to "Extended" or "Dual display independent".
- ADB命令(如果UI找不到选项):
- Check available displays first to confirm IDs:
You'll see entries likeadb shell dumpsys displayDisplay 0: LCDandDisplay 1: HDMI(order might vary). - Disable mirroring:
adb shell settings put global mirror_display 0 - Set extended mode (if needed):
adb shell settings put global display_mode 1
- Check available displays first to confirm IDs:
2. 方案一:修改自定义APK以指定显示输出
If you have access to the custom APK's source code, this is the most reliable method:
- In your APK's main Activity, add code to attach its window to the HDMI display (adjust display ID based on your dumpsys output):
import android.hardware.display.DisplayManager; import android.view.Display; import android.view.WindowManager; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); // Get DisplayManager and list of available displays DisplayManager displayManager = (DisplayManager) getSystemService(Context.DISPLAY_SERVICE); Display[] displays = displayManager.getDisplays(); // Assume HDMI is Display 1 (verify with dumpsys display) Display hdmiDisplay = null; for (Display display : displays) { if (display.getName().contains("HDMI")) { hdmiDisplay = display; break; } } // Attach the app's window to HDMI display if (hdmiDisplay != null) { WindowManager.LayoutParams params = getWindow().getAttributes(); params.displayId = hdmiDisplay.getDisplayId(); getWindow().setAttributes(params); } } - Your video player (either system default or a custom one) will run on the main display (LCD) by default, no extra changes needed.
3. 方案二:无需修改APK,用ADB强制指定显示输出
If you can't modify the custom APK, use ADB commands to launch it directly on the HDMI display:
- Step 1: Launch the custom APK on the target display (replace
com.your.package/com.your.package.MainActivitywith your APK's component, and1with your HDMI display ID):adb shell am start -n com.your.package/com.your.package.MainActivity --display 1 - Step 2: Launch your video player on the main display (LCD, display ID 0, optional if you're using the system player manually):
adb shell am start -n com.android.videoplayer/com.android.videoplayer.VideoPlayerActivity --display 0 - If the APK is already running, you can move its window to HDMI:
- Get the APK's window ID:
Extract the window ID (the number afteradb shell dumpsys window windows | grep mCurrentFocusWindow{), then run:adb shell service call window 1 i32 <window_id> i32 <hdmi_display_id>
- Get the APK's window ID:
4. 验证与故障排除
- After setting up, run
adb shell dumpsys displayagain to confirm each display has its own content. - If the custom APK doesn't show up on HDMI, check:
- The display ID is correct (you might have mixed up LCD and HDMI IDs).
- Your TI board's Android Marshmallow build supports multi-display extension mode (most TI industrial boards do, but verify with TI's docs if needed).
- For video playback, make sure the video player isn't set to mirror output in its own settings.
内容的提问来源于stack exchange,提问作者dasariarun
相关产品推荐
相关产品推荐

