Add the following line to the dependencies in the build.gradle
file.
compile 'com.clickyab:clickyab-sdk:1.3.3:mainRelease@aar'
Make sure to add dependency to the module level build file and not the
build.gradle
file in root of your project. Also make sure jcenter()
is
in your repositories.
Download the AAR library from releases and add it to your project:
- Go to File>New>New Module
- Select “Import .JAR/.AAR Package” and click next.
- Enter the path to .aar file and click finish.
- Go to File>Project Structure (Ctrl+Shift+Alt+S).
- Under “Modules,” in left menu, select “app.”
- Go to “Dependencies tab.
- Click the green “+” in the upper right corner.
- Select “Module Dependency”
- Select the new module from the list.
If you need the JAR format (not recommended) download it from releases. The JAR format does not have the progress indicator by default, but you can provide you own (see Customizing).
Remember to add INTERNET
and ACCESS_COARSE_LOCATION
permissions to AndroidManifest.XML
.
Add one one the three size of banners to you layout. Remember to put your token.
<com.clickyab.Banner
android:layout_width="wrap_content"
android:layout_height="wrap_content"
token="token"
/><!-- 320*50 dp -->
<com.clickyab.LargeBanner
android:layout_width="wrap_content"
android:layout_height="wrap_content"
token="token"
/><!-- 300*250 dp -->
<com.clickyab.XlargeBannerPortrait
android:layout_width="wrap_content"
android:layout_height="wrap_content"
token="token"
/><!-- 320*480 dp -->
For fulscreen banner, create one and call the method show
.
ClickYabFullAd banner = new ClickYabFullAd(getContext() , "token");
banner.show();
You can also add listeners to banners. Note that the listeners are called multiple times. Ads are reloaded every few minutes and on every reload the listeners are called once.
largeBanner = (LargeBanner) findViewById(R.id.largeBanner);
largeBanner.setClickYabAdListener(new ClickYabAdListener() {
@Override
public void onLoadFinished() {
// Called when loading is finished
}
@Override
public void onNoAds(int errorCode, String description) {
// Called when there is no ads to display
}
@Override
public void onClose() {
// Called when user closes the ad
}
});
}
You can set onClickListener for banners:
XlargeBannerPortrait banner = (XlargeBannerPortrait) findViewById(R.id.xlargeBannerPortrait);
banner.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
}
});
You can disable the progress indicator:
XlargeBannerPortrait banner = (XlargeBannerPortrait) findViewById(R.id.xlargeBannerPortrait);
banner.setHasProgressBar(false);
Or using progress
in XML attribute:
<com.clickyab.Banner
android:layout_width="wrap_content"
android:layout_height="wrap_content"
progress="false"
token="token"
/><!-- 320*50 dp -->
You can provide your own progress indicator drawable:
XlargeBannerPortrait banner = (XlargeBannerPortrait) findViewById(R.id.xlargeBannerPortrait);
banner.setProgressDrawable(getDrawable(R.id.custom_drawable));
You can set a timeout for loading ads. If the ad is not loaded after timeout, onNoAds()
is called.
Default timeout is 10 seconds.
XlargeBannerPortrait banner = (XlargeBannerPortrait) findViewById(R.id.xlargeBannerPortrait);
banner.setTimeOutSeconds(10);
Or using timeout
in XML attribute:
<com.clickyab.Banner
android:layout_width="wrap_content"
android:layout_height="wrap_content"
timeout="10"
token="token"
/><!-- 320*50 dp -->
If there is no ads, visibility is automatically changed to View.GONE
by default. You can change this by setting auto-hide to false;
XlargeBannerPortrait banner = (XlargeBannerPortrait) findViewById(R.id.xlargeBannerPortrait);
banner.setAutoHide(false);
Or using autohide
in XML attribute:
<com.clickyab.Banner
android:layout_width="wrap_content"
android:layout_height="wrap_content"
autohide="false"
token="token"
/><!-- 320*50 dp -->
-keepclassmembers class com.clickyab.ClickYabJavascriptInterfaceImpl {
public *;
}
-keep public interface com.clickyab.ClickYabAdListener {*;}
-keep class com.clickyab.ClickYabFullAd {
public *;
}
-keep public class * extends com.clickyab.ClickYabBanner
-keepclassmembers class * extends com.clickyab.ClickYabBanner {
public <init>(android.content.Context);
public <init>(android.content.Context, android.util.AttributeSet);
public <init>(android.content.Context, android.util.AttributeSet, int);
}
Documents at https://www.clickyab.com/blog/clickyab-android-sdk-document/ are outdated and will be updated soon.