Android(安卓)利用presentation实现双屏异显
16lz
2021-01-26
我的思路是在主屏中开启activity,然后在副屏中开启服务,通过服务我们就可以让副屏一直显示或者播放节目或者打开其他应用,哪怕是退主屏退出activity。
// 获取显示设备。 public void updateContents() { mDisplayManager = (DisplayManager) getSystemService( Context.DISPLAY_SERVICE); Display[] displays = mDisplayManager.getDisplays(); showPresentation(displays[1]); }
// 将内容显示到display上面。private void showPresentation(Display display) { myPresentation = new MyPresentation(this, display); myPresentation.setOnDismissListener(new DialogInterface.OnDismissListener() { @Override public void onDismiss(DialogInterface dialog) { // 监听消失,保存当前播放位置。 sharedPreferences.edit().putInt("index", nowHdmiPosition).commit(); sharedPreferences.edit().putInt("position", mBackgroundPlayer.getCurrentPosition()).commit(); } }); myPresentation.getWindow().setType(WindowManager.LayoutParams.TYPE_PHONE); myPresentation.show(); presentSurface = myPresentation.getSurface(); presentSurface.getHolder().addCallback(new MySurfaceCallback());}
源码下载链接:
http://download.csdn.net/detail/bestchenq/9561946
更多相关文章
- android singleTask使用情况,场景分析
- android 标题栏不显示?
- android 虚拟机网络问题处理
- Android(安卓)Window理解(3.1)---子窗口创建过程:Dialog、PopupWind
- android 视频播放 JiaoZiVideoPlayer使用分析
- TextView 文本过长时自动打点
- Android的震动与振铃
- Android(安卓)Fragment学习笔记(二)
- android关于popupWindow不显示