psamim / android-sample

Clickyab sdk android sample

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ClickYab Sample App for Android

مستندات فارسی

How To Add ClickYab SDK to Your Project

Add to your dependencies

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.

Or Manually Add AAR file

Download the AAR library from releases and add it to your project:

  1. Go to File>New>New Module
  2. Select “Import .JAR/.AAR Package” and click next.
  3. Enter the path to .aar file and click finish.
  4. Go to File>Project Structure (Ctrl+Shift+Alt+S).
  5. Under “Modules,” in left menu, select “app.”
  6. Go to “Dependencies tab.
  7. Click the green “+” in the upper right corner.
  8. Select “Module Dependency”
  9. Select the new module from the list.

Or Manually Add JAR file

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.

How to Use

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();

Adding listeners

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) {

        }
    });

Customizing

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 -->

Proguard Rules

-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);
}

Warning

Documents at https://www.clickyab.com/blog/clickyab-android-sdk-document/ are outdated and will be updated soon.

About

Clickyab sdk android sample


Languages

Language:Java 100.0%