Reputation: 3887
I've implemented Banner Ads in my Android game and I'm wondering what is the 'correct' way to hide these ads? I'm hiding ads during actual game-play and at the moment, I have a couple of simple methods that handle this for me:
public void hideAd(){
adView.setVisibility(View.GONE);
}
public void showAd(){
adView.setVisibility(View.VISIBLE);
}
Is this the 'correct' way. I'm currently not pausing and resuming the adView like so:
public void hideAd(){
adView.setVisibility(View.GONE);
adView.pause;
}
public void showAd(){
adView.setVisibility(View.VISIBLE);
adView.resume();
}
What are the implications (if any) of not using the pause() and resume() methods? Or, indeed the implications (if any) of using these the pause() and resume() methods? Which is the correct/best way?
Upvotes: 2
Views: 2286
Reputation: 7927
According to the documentation:
public void pause ()
Pauses any extra processing associated with an AdView and should be called in the parent Activity's
onPause()
method.public void resume ()
resumes an AdView after a previous call to pause() and should be called in the parent Activity's
onResume()
method.
Any Implications?
In your first code snippet, the ads will run when you hide ads affecting your game's performance. (Example, decrease in FPS)
Use the second code snippet to prevent ads from running when you hide ads. This will boost performance by preventing all extra processing such as loading/refreshing ads
Upvotes: 3