Unable to handle alert pop up

I’m new to appium, I’m using an android emulator and trying to handle a pop-up. I used the below code
public void allowAppPermission() throws InterruptedException{
wait.until(ExpectedConditions.alertIsPresent());
driver.switchTo().alert().accept();
}

But it throws an error saying no alert is present. Actually the problem is its dynamic pop up i.e, sometimes 2pop-up appears one after other with 3sec gap and sometimes no pop-up appears at all. So Can anyone help me with how to handle this problem? Thank you in advance