1.如何獲取設備上的屏幕?數組
DisplayManager mDisplayManager;//屏幕管理類ide
Display[] displays;//屏幕數組.net
mDisplayManager = (DisplayManager)context.getSystemService(Context.DISPLAY_SERVICE);繼承
displays =mDisplayManager.getDisplays();get
2.主屏和副屏的區分?io
主屏:displays[0]class
副屏:displays[1]layout
3.如何在副屏上展現內容?di
經過Presentation來實現,Presentation繼承了Dialog。假設咱們寫了一個DifferentDislay的類,這個類是要繼承 vi
Presentation類的。代碼:
privateclass DifferentDislay extends Presentation{
public DifferentDislay(ContextouterContext, Display display) {
super(outerContext,display);
//TODOAuto-generated constructor stub
}
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();