Android 利用presentation实现双屏异显
2016-06-28 16:14
591 查看
我的思路是在主屏中开启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 ADB server didn't ACK * failed to start daemon * 简单有效的解决方案
- android alterdialog 背景和大小问题
- 读取Android GPS NMEA数据
- Android ScrollView 长截屏
- Android EditText 常见问题总结
- Android 使用SpannableString在TextView中插入表情、超链接、文字变大、加粗
- android中的本地定时推送到通知栏
- 第一个Android jni开发资料(NDK)
- 理解Android Framework
- Android中自定义View的状态保存
- RecyclerView总结学习(二)
- Android控件之SeekBar 设置最小值非零
- Android提高Service优先级的方法分析
- android EventBus 3.0 混淆配置
- 如何在onCreate里面绘制View宽高
- Android 自定义RecyclerView 实现真正的Gallery效果
- Android——操作摄像头、图片合成
- android GPS 定位
- Android中使用Canvas绘制简单的图形(一)
- Android中persistent属性用法详解