How to handle Alert box / Pop up using JAVA for Android?

Yeah, I had the same problem and got me crazy until i decided to check if the alert is shown by looking for tittle and button label patterns.
I dont think its the best scenario for this, doesnt look “safe” to build tests around elements with id like “button1”, but i guess its the only option for now.