Android SDK Code

Android SDK 2.2 Beta

- Consistent with Google Play's latest policy (Updated from 8/1/2014)
 

 DownloadAdFlex SDK

- Get AdFlexLib_2.2_beta.jar and put into libs of project

Download AdFlexLib_2.2.jar

- Get sample code which is integrated AdFlex SDK

Sample Code

 Add Google Play Service

AdFlex 2.2 Beta version needs to be added Google Play Service, see guideline HERE to put Google Play Service into project

 Update AndroidManifest.xml

Add Service (in Application)

<service android:name="mobi.mclick.ad.AdsService" android:process=":adflexService"/>

Add activities

<activity android:name="mobi.mclick.ad.AdsActivity" android:theme="@android:style/Theme.Translucent.NoTitleBar" android:configChanges="keyboardHidden|orientation|screenSize">

Add meta-data

<meta-data android:name="mobi.mclick.ad.publisher.id" android:value="{$username}"/>

Add permissions

<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>

 Interstitial Ads (Fullscreen)

Add into Code Activity of app

import mobi.mclick.ad.*;

 public class InterstitialActivity extends Activity implements AdsListener {
   private InterstitialAds interstitialAds;

   @Override
     public void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
         setContentView(R.layout.interstitial);
         interstitialAds = new InterstitialAds(this);
         interstitialAds.setAdsListener(this);
         interstitialAds.loadAds(new AdsRequest());
     }

   @Override
     public void onAdsLoaded(Ads ads) {
         if (ads == interstitialAds) {
             interstitialAds.show();
         }
     }
 }
                    

 Banner Ads

AdsView can be added directly into XML as normal view

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:adx="http://schemas.adflex.asia/apk/lib/ads"
android:orientation="vertical"
android:layout_width="fill_parent" android:layout_height="fill_parent">
    <mobi.mclick.ad.AdsView android:id="@+id/adsView"
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            adx:x_type="BANNER"/>
</LinearLayout>

Add into Code Activity of app directly

import mobi.mclick.ad.*;
public class BannerExample extends Activity {
    private AdsView adsView;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        /*tạo AdsView*/
        adsView= new AdsView(this);

        /*Find layout containing banner ads*/
        LinearLayout layout = (LinearLayout)findViewById(R.id.adsLayout);

        /*Add adsView*/
        layout.addView(adsView);

        /*load ads*/
        adsView.loadAds(new AdsRequest());
    }
}


Use function removeBannerAds() of object adsView

adsView.removeBannerAds();

 Floating Icon Ads

Call Method to display giftbox in Activity

MobileAd.showGift(*activity*, *int position*);

Position can be one of these values:

 

  1. MobileAd.GIFT_BOTTOM_LEFT
  2. MobileAd.GIFT_BOTTOM_RIGHT
  3. MobileAd.GIFT_BOTTOM_CENTER
  4. MobileAd.GIFT_TOP_LEFT
  5. MobileAd.GIFT_TOP_RIGHT
  6. MobileAd.GIFT_TOP_CENTER
  7. MobileAd.GIFT_CENTER_LEFT
  8. MobileAd.GIFT_CENTER_RIGHT
  9. MobileAd.GIFT_CENTER_SCREEN

 Obfuscate sourcecode guildeline

If you want to obfuscate to protect the processing logic of the application, you must follow these steps to avoid conflicts error between your obfuscate and sourcecode of AdFlex

Add Settings

-keep class mobi.mclick.ad.*{ *; }

into file proguard.cfg of project

Download sample settings file: http://sdk.adflex.vn/dev/proguard-android.txt

Business Supporter

  • ...

    Anh HT

    anhht@eway.vn
    anne.adflex
Report Error

Cảm ơn bạn đã gửi nhận xét.
Nhận xét của bạn là đóng góp quan trọng cho AdFlex để phục vụ bạn tốt hơn!