Is there a way to check if android WindowManager already contains a view?
You can check to see if the view's window token is null:
if(view.getWindowToken() != null){
WindowManager.removeView(view);
}
You could also just catch the exception:
try{
WindowManager.removeView(view);
}catch(IllegalArgumentException e){
Log.e(debug_tag, "view not found");
}
Its also a better way to check its already added on window or not.
if (view.getParent() != null)) {
windowsManager.removeView(view);
}