1.如何获取设备上的屏幕?
DisplayManager mDisplayManager;//屏幕管理类
Display[] displays;//屏幕数组
mDisplayManager = (DisplayManager)context.getSystemService(Context.DISPLAY_SERVICE);
displays =mDisplayManager.getDisplays();
2.主屏和副屏的区分?
主屏:displays[0]
副屏:displays[1]
3.如何在副屏上展示内容?
通过Presentation来实现,Presentation继承了Dialog。假设我们写了一个DifferentDislay的类,这个类是要继承
Presentation类的。代码:
privateclass DifferentDislay extends Presentation{
public DifferentDislay(ContextouterContext, Display display) {
super(outerContext,display);
//TODOAuto-generated constructor stub
}
@Override
protectedvoid onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.diffrentdisplay_basket);
}
}
4.开启副屏
DifferentDislay mPresentation =new DifferentDislay (getApplicationContext(),displays[1]);//displays[1]是副屏
mPresentation.getWindow().setType(
WindowManager.LayoutParams.TYPE_SYSTEM_ALERT);
mPresentation.show();