public Context mSecondScreenContext;
private WindowManager mWindowManager;
private WindowManager.LayoutParams mLayoutParams;
private View mView;
public void displaySecondScreen(Context context) {
DisplayManager mDisplayManager = (DisplayManager) context.getSystemService(Context.DISPLAY_SERVICE);
Display[] displays = mDisplayManager.getDisplays();
if (displays.length > 1) {
//mContext = createDisplayContext(displays[displays.length - 1]);
mSecondScreenContext = context.createDisplayContext(displays[1]);
} else {
mSecondScreenContext = null;
}
mWindowManager = (WindowManager) mSecondScreenContext.getSystemService(Context.WINDOW_SERVICE);
mLayoutParams = new WindowManager.LayoutParams(WindowManager.LayoutParams.MATCH_PARENT,
WindowManager.LayoutParams.MATCH_PARENT,
0, 0,
PixelFormat.TRANSPARENT);
mLayoutParams.gravity = Gravity.CENTER;
mLayoutParams.x = 0;
mLayoutParams.y = 0;
mLayoutParams.flags = WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
| WindowManager.LayoutParams.FLAG_FULLSCREEN
| WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS
| WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN
| WindowManager.LayoutParams.FLAG_BLUR_BEHIND
| WindowManager.LayoutParams.FLAG_LAYOUT_INSET_DECOR
| WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH;
mLayoutParams.type = WindowManager.LayoutParams.FIRST_SYSTEM_WINDOW + 100;
mView = LayoutInflater.from(mSecondScreenContext).inflate(R.layout.common_alert_window, null);
}
09-10
1万+
