When I developed my drinking game Drunk Green Robots my focus was on making money from in app purchases and not ads. This has worked decently well. I average .10 from each install (I just need more installs to make better money). The way the game is written the user moves between activities pretty quickly and I’m constantly creating new activities and finishing the old ones.
The bad news. This is horrible for ads. I realized this rather quickly and removed ads from all activites except the two that the user is likely to stay on the longest. But still most ads probably show at most for 5 to 10 seconds before the user moves to a new activity.
Why don’t I remove them altogether? Because I do make some money from them and even more importantly one of my in app purchases is to remove ads (which I’ve made an ok number of sales on). So I just opted to leave the poor performing ads in there.
Now I’m tired of seeing eCPM of .05 on these and a CTR of .12%. I’m ready to do something about it. I’ve always thought it would be perfect to have the ads constant at the bottom and only refresh them every 2 minutes regardless of the activity. But I never really knew how to do it. I recently saw this and it talked about having the same ad across multiple screens but didn’t tell how it acomplished it.
So I went searching and saw somebody suggest this
I’m keeping in mind that you can afford to leak 1 activity, as this is the only solution I know: Declare a static view, say myAdView in your 1st activity (in which you are requesting ad). Now you can ad and remove this myAdView in every activity transation. Ofcource you will have to maintain seperate LinearLayouts for ur ads in seperate activities, where we will add/remove the myAdView eg. Suppose you are going from activity A to B, then in A’s onPause remove myAdView:
private LinearLayout layoutAd;
layoutAd = (LinearLayout) findViewById(R.id.layout_ad); // from A’s xml
protected void onPause() {
super.onPause();
layoutAd.removeView(FirstActivity.adBannerView);
}
and in B’s onResume add the same (FirstActivity’s) myAdView:
private LinearLayout layoutAd;
layoutAd = (LinearLayout) findViewById(R.id.layout_ad); // from B’s xml
protected void onResume() {
super.onResume();
layoutAd.addView(FirstActivity.adBannerView);
}
But this just seems messy and wrong to me. Even though they say it works.
Somebody in that post suggested fragments. But when I looked more into how fragments worked I realized that each instance of that fragment is tied to one activity and adding the fragment to another meant creating antoher instance of that fragment. Definately doesn’t solve my problem.
Saw this which talked about retaining instance of a fragment. But in this example the fragment being retained was just a background thread and the main fragment UI got recreated. Plus is was still tied to one activity.
So while I was thinking about fragments I thought the best way would be to have one main activity that the user stays in… it has my action bar at the top and an ad at the bottom. The ad refreshes every 2 minutes. Then change each of my activites into fragments. And replace the same middle section with differnt fragments as the user navigates through the game. I made a little test app and this seemed to work fine. I do need to make sure the fragments get disposed of correctly since I will be constantly creating new ones and replacing the old ones (just like I currently do with my activities).
Does anybody know of a better way to accomplish a static ad at the bottom that can refresh when I want it to instead of during each new activity? Anything wrong with the method I’m thinking about? It seems like it will be alot of work but I don’t know a better way of doing it.