Advertising in the application - this is a very important point, and sometimes the only income.
I think many people wondered what kind of advertising is better and where it is better to place it. Each application is individual, so you need to experiment.
To release an app update every time with experiments? Not an option. It is much better to store all settings on the server side, and in the application to implement the logic of advertising.
')
But is everything so simple?
The purpose of this post:
- make a small contribution to open source (
source code ,
demo )
- get adequate criticism
- find developers who are ready to support the project
- popiarit the application
Prices in China , where this approach is used
Foreword
Just want to say that I am not a very experienced Android / Java developer. I program mainly in php (more than 5 years). This is my first android application, so do not judge strictly.
Library features
Types of advertising
- admob
- StartAd.mobi
- your banner, written in the form of html
Display
- Bottom
- above
- In the list (with a given step)
- Inside the specified element (specify the id of the element)
- Interstitial advertising (full screen)
Examples of using
Admob bottom
AdMob ad = new AdMob(activity, adMobId); AdManager manager = new AdManager(ad); manager.show(Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL);

Admob smart
If you need to stretch the entire width of the screen
adMob.setAdSize(AdSize.SMART_BANNER);

Your banner on top
AdCustom ad = new AdCustom(activity, html); AdManager manager = new AdManager(ad); manager.show(Gravity.TOP | Gravity.CENTER_HORIZONTAL);

In the list in increments of 15
AdListAdapter adapter = new AdListAdapter(oldAdapter); AdMob ad = new AdMob(activity, adMobId); adapter.setStep(15); adapter.setAd(ad); adapter.notifyDataSetChanged();

In a specific place
<LinearLayout android:id="@+id/inline_banner" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical" /> AdStartAd ad = new AdStartAd(activity, startadId); AdManager manager = new AdManager(ad); manager.showInView("inline_banner");

Interstitial banner
AdMobInterstitialAd ad = new AdMobInterstitialAd(activity, admobId); ad.show();

Server side settings
new AdsLoadTask(getActivity(), sectionNumber, adapter, "android").execute();
Connect to the project
At the moment it is not a library, but a regular application. To use it in your application, do the following:
- transfer libraries from libs folder
- update dependencies in build.gradle
compile 'com.google.android.gms:play-services:4.0.30' compile files('libs/StartADLib-1.0.1.jar') compile 'com.google.code.gson:gson:2.2.4@jar'
- change AndroidManifest.xml
<meta-data android:name="email" android:value="you@email" /> <meta-data android:name="trackingId" android:value="yourid" /> <meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" /> <activity android:name="com.google.android.gms.ads.AdActivity" android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" />
Future plans
- implement backend for server settings. I have already implemented this in the project, but I need to somehow transfer it.
- statistics of hits (also implemented) and clicks
- add more types of ads
- fix TODO and FIXME in code
- arrange in the form of a library (and not in the form of a project with copying files to the right places)
- put in maven repository
Help
As always, there is not enough time, so any help from the developers will not hurt. Let's not be shy to do something and show it to others. I remembered the saying "Do not be afraid to make a mistake, be afraid not to try." I do not ask to realize something supernatural. Just if you use some of this in your project and decide to add something new, or if you find a bug, do not be lazy, send a pull request.
Experiments and conclusions
I experimented with advertising a lot (2 months) and found the best option for myself. Many users do not like it, but managed to increase the CTR from 0.2 to 0.9. There will be time - I will share statistics on the application (traffic, estimates, profit). Already have a little experience and have something to tell.