При вызове removeViev() окно не закрывается на android 5.0 (возможно на других версиях тоже, не проверял). Код взял отсюда, так как делаю приложение со сходным функционалом.
private void showWindow(Context context, String phone) {
windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
LayoutInflater layoutInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
WindowManager.LayoutParams params = new WindowManager.LayoutParams(
WindowManager.LayoutParams.MATCH_PARENT,
WindowManager.LayoutParams.WRAP_CONTENT,
WindowManager.LayoutParams.TYPE_SYSTEM_ALERT,
WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL,
PixelFormat.TRANSLUCENT);
params.gravity = Gravity.TOP;
windowLayout = (ViewGroup) layoutInflater.inflate(R.layout.info, null);
TextView textViewNumber=(TextView) windowLayout.findViewById(R.id.textViewNumber);
Button buttonClose=(Button) windowLayout.findViewById(R.id.buttonClose);
textViewNumber.setText(phone);
buttonClose.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
closeWindow();
}
});
windowManager.addView(windowLayout, params);
}
private void closeWindow() {
if (windowLayout !=null){
windowManager.removeView(windowLayout);
windowLayout =null;
}
}
}
Как вести несколько рекламных аккаунтов в антидетект-браузере
Подготовка и масштабирование рекламных кампаний в среде Linken Sphere