Handling intermittent advertisements in Gaming Native app

I am automating Android Native Gaming App, our app renders ads from different ad networks. After submitting each game you may see static ad and video ad or you may not see an ad at all. If video ad is found it may vary from 30 secs to 1 min.
Important thing, when i use Appium inspector to spy various video ad screens shall be identified only by Class(android.webkit.WebView, android.widget.VideoView, android.widget.Button, android.view.View, android.widget.Image & android.widget.ImageView.). After Ad complete playing we need to click on device back button and play next game.
Can you suggest any good approach to automate this kind of app? Any sample code is much appreciated.

Take a look at Implicit Waits:

https://www.seleniumhq.org/docs/04_webdriver_advanced.jsp

That will allow you to poll the app until the ad is over & return to workflow.