How to use AdWhirl with an unsupported ad company?
Does anyone know how AdWhirl works?
I set up my custom event for Greystripe in which I initialize the SDK if it wasn't already initialized, and refresh the BannerView, but I don't see the custom event getting called. So my main question is, how and when does AdWhirl call the custom event? What are the rations and rollovers? I haven't done anything with them (mainly because I don't know why I need them. What does AdWhirl do with them?)
Also, how do I control when AdWhirl refreshes my banner? I'd like to tie the refresh with a button action.
I've been searching online nonstop for the past two days and read a lot of tutorials and example Java classes that people have shared, but none of them have worked. It just looks like AdWhirl is stagnate. It's so unclear to me how AdWhirl works beyond: it mediates between the app and all the ad opportunities you want to use in your ad. That's an entirely too high-level u开发者_StackOverflownderstanding for me to move forward. :(
Have you read the wiki page that describes how to use Custom Events? You basically create a custom event in the backend UI which behaves like another ad network, and you can configure it's traffic. Then you can implement the function name that you named in the backend. The only unintuitive part is that you have to implement AdWhirlInterface to listen for the custom event, which means creating an adWhirlGeneric() method. This method can be empty though, I am not seeing it called when creating my own test event. Finally, make sure to set the AdWhirlInterface.
So assuming on the backend you created a network with:
Name: Test Network
Function Name: testEvent
and gave it traffic (I recommend giving it 100% traffic when testing), then your code would look something like this:
public class MyActivity extends Activity {
...
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
...
}
...
public void testEvent() {
// Place event code here.
Log.d("Cust_Network", "Cust network got called!");
}
}
To control refreshing your ad, call rotateThreadedNow() on the AdWhirlLayout when a button is clicked, for example. This will take AdWhirl through the process of randomly determining a new ad network, and calling the correct adapter, or custom event in this case. If you choose to go this route, you may not want automatic refreshing, in which case you should disable automatic refreshing on the back end.
The ration object is populated with data from the configuration data. Each ration represents an ad network, and has keys which represent the individual ad network ids, weight percentages that you set in the backend, and backfill priority. Backfill priority is the network order that AdWhirl will request from if the original request did not fill. This process of going through backfill priority is called rollover. You will need to know a little bit about rollover when implementing your own custom event.
The wiki page mentioned has these recommendations to add to your custom event:
// In your custom event code, you'll want to call some of the below methods.
//
// On success:
// this.adWhirlLayout.adWhirlManager.resetRollover();
// this.adWhirlLayout.rotateThreadedDelayed();
//
// On failure:
// this.adWhirlLayout.rolloverThreaded();
If your custom event properly fetches an ad, you will want to reset the rollover order (so the next request will have the correct backfill order), and call rotateThreadedDelayed() so that a refresh will happen automatically in the amount of time you specified on the back end. If the ad request failed, you will want to call rolloverThreaded() so that AdWhirl can go through it's rollover process to check your other configured ad networks for ads.
if you want you can use an open source library i've developed that allows to use AdWhirl with other (unsupported) ad networks (but also with the officially supported ones). This library is also extensible, so you can add a new network to it and manage easily through AdWhirl.
The library is AdMAL (Ad Mediation Abstraction Layer) and is available on a github.com repository under the Apache 2.0 open source license: https://github.com/marcosiino/AdMAL
Using AdMAL you can easily implement AdWhirl in your applications for both supported and unsupported network (the integration is easiest than implementing AdWhirl SDK). Actually it only supports iOS (it's developed in Objective-C), but i plan to port to android in the next months.
I started AdMAL for my own purposes, then decided to release it to the public under an open source license some days ago. Hope this help! I encourage other developers to improve the library and implement new networks support, so that this can benefit to everyone.
精彩评论