Skip to content

yesup/partner-sdk

Repository files navigation

Yesup Partner Sdk for Android

The Latest SDK Version: 1.2.6

Yesup Partner SDK for Android is the easiest way to integrate your Android app with Yesup.
#####        1 Install Yesup AD SDK
#####        2 Set your custom information
#####        3 Use OfferWall
#####        4 Use Intersitial
#####        5 Use Banner
Learn more about the provided sample at https://github.com/yesup/house-reminder


### **1** Install Yesup AD SDK
a. Download yesup partner config file "adconfigure.xml".
b. Copy adconfigure.xml file to your "res/xml/adconfigure.xml" directory.
Note: Do not modify this file name!!!
c. In Android Studio, open the build.gradle file which is in your project's root directory, make sure that you have used the JCenter like below:
```python allprojects { repositories { jcenter() } } ``` d. In Android Studio, open the app's build.gradle file in the editor.
Add a "dependencies" source, as follows:
```python dependencies { compile 'com.yesup.partner:yesuppartner:1.2.6' } ``` Now the classes and methods in the Yesup Partner Library can be used in your app.

### **2** Set your custom information
a. Import package.
```python import com.yesup.partner.YesupAd; ``` b. Set custom information like below:
```python @Override protected void onCreate(Bundle savedInstanceState) { String subId = "123123"; // optional, you app user id String optValue1 = ""; // optional, additional event value you want to keep track String optValue2 = ""; // optional, additional event value you want to keep track String optValue3 = ""; // optional, additional event value you want to keep track YesupAd.setSubId(subId); YesupAd.setOption(optValue1, optValue2, optValue3); } ```
### **3** Use OfferWall
a. Add in the following line to your AndroidManifest.xml to declare the Activity:
You can modify the android:label, this property will display on the title of activity.
```python ``` b. new and set a OfferWallHelper object, you can control the view of rewards button(rewards and icon).
c. Write code below to use OfferWall:
```java import com.yesup.partner.YesupOfferWall;

public class MainActivity extends AppCompatActivity { private YesupOfferWall offerwallAd;

@Override
protected void onCreate(Bundle savedInstanceState) {
    offerwallAd = new YesupOfferWall(this);
    offerwallAd.setOfferWallPartnerHelper(new OfferWallHelper(this));
}

@Override
protected void onResume() {
    super.onResume();
    if (null != offerwallAd) {
        offerwallAd.onResume();
    }
}

public class OfferWallHelper extends OfferWallPartnerHelper {
    public OfferWallHelper(Context context) {
        super(context);
    }

    @Override
    public String calculateReward(int payout, int incentRate) {
        String result = "0";
        double reward = (double)payout * (double)incentRate / 100000.0D;
        if(0.0D == reward) {
            result = "";
        } else {
            result = (new DecimalFormat("#.##")).format(reward);
        }

        return result;
    }

    @Override
    public Drawable getRewardIcon() {
        Drawable drawable = context.getResources().getDrawable(R.drawable.coins);
        return drawable;
    }
}

}

  c. Use code "offerwallAd.showDefaultOfferWall();" to start an OfferWall activity.


<div id="step4"></div>
### **4** Use Intersitial<br/>
  a. Import package.<br/>
```java
import com.yesup.partner.YesupInterstitial;

b. In order to use Interstitial AD, you must implement IInterstitialListener interface in your activity which need to call the interstitial.
c. In onCreate method, new an YesupAd and MyStatusView instance, MyStatusView object can control the view that below the intersitial ad.
c. Example code:

public class MainActivity extends AppCompatActivity
        implements IInterstitialListener {
    private YesupInterstitial interstitialAd;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        interstitialAd = new YesupInterstitial(this);
        partnerView = new InterstitialPartnerView(this);
    }
    @Override
    public void onInterstitialShown() {
        Log.i(TAG, "On Interstitial Shown");
    }

    @Override
    public void onInterstitialCredited() {
        Log.i(TAG, "On Interstitial Credited");
    }

    @Override
    public void onInterstitialClosed() {
        Log.i(TAG, "On Interstitial Closed");
    }

    @Override
    public void onInterstitialError() {
        Log.i(TAG, "On Interstitial Error");
        interstitialAd.closeNow();
    }

    public void startInterstitial() {
        interstitialAd.showDefaultInterstitial(false, true, partnerView);
    }
}
### **5** Use Banner
a. Add Banner in your layout file.
```java
<com.yesup.ad.banner.BannerView
    android:layout_alignParentBottom="true"
    android:layout_width="320dp"
    android:layout_height="50dp"
    android:layout_centerHorizontal="true"
    yesupad:yesup_banner_zone_id="72586"
    android:id="@+id/yesupBannerAdBottom" />
``` b. Add code to show Banner ad.
```java public class MainActivity extends AppCompatActivity { private BannerView bannerAdBottom;
@Override
protected void onCreate(Bundle savedInstanceState) {
    bannerAdBottom = (BannerView)findViewById(R.id.yesupBannerAdBottom);
}

@Override
protected void onResume() {
    super.onResume();
    if (null != bannerAdBottom) {
        bannerAdBottom.onResume();
    }
}

@Override
protected void onPause() {
    super.onPause();
    if (null != bannerAdBottom) {
        bannerAdBottom.onPause();
    }
}

}

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages