GithubHelp home page GithubHelp logo

isabella232 / startapp_inapp_sdk_example Goto Github PK

View Code? Open in Web Editor NEW

This project forked from startapp-sdk/startapp_inapp_sdk_example

0.0 0.0 0.0 7.15 MB

StartApp InApp Android SDK Example Project

Home Page: www.startapp.com

License: Other

Java 100.00%

startapp_inapp_sdk_example's Introduction

StartApp SDK Example

This project provides an example of the StartApp SDK integration for Android.

The example application contains the following ads:

  • Banner
  • Interstitial ad
  • Rewarded video
  • RecyclerView with Banner
  • RecyclerView with NativeAd

Add dependency

app/build.gradle

repositories {
    mavenCentral()
}

dependencies {
    // noinspection GradleDynamicVersion
    implementation 'com.startapp:inapp-sdk:4.8.+'
}

Update AndroidManifest.xml

<!-- Add these permissions for better ad targeting -->
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.BLUETOOTH" />

<application>
    <!-- TODO replace YOUR_APP_ID with actual value -->
    <meta-data
        android:name="com.startapp.sdk.APPLICATION_ID"
        android:value="YOUR_APP_ID" />
</application>

Set up test ad

MainActivity.java

@Override
protected void onCreate(Bundle state) {
    super.onCreate(state);

    // NOTE always use test ads during development and testing
    StartAppSDK.setTestAdsEnabled(BuildConfig.DEBUG);

    setContentView(R.layout.main);
}

Add Banner into xml layout

<com.startapp.sdk.ads.banner.Banner
    android:layout_width="wrap_content"
    android:layout_height="wrap_content" />

Show interstitial ad

public void someMethod() {
    // start your next activity
    startActivity(new Intent(this, OtherActivity.class));

    // and show interstitial ad
    StartAppAd.showAd(this);
}

Show rewarded video

public void showRewardedVideo() {
    final StartAppAd rewardedVideo = new StartAppAd(this);

    rewardedVideo.setVideoListener(new VideoListener() {
        @Override
        public void onVideoCompleted() {
            // Grant the reward to user
        }
    });

    rewardedVideo.loadAd(StartAppAd.AdMode.REWARDED_VIDEO, new AdEventListener() {
        @Override
        public void onReceiveAd(Ad ad) {
            rewardedVideo.showAd();
        }

        @Override
        public void onFailedToReceiveAd(Ad ad) {
            // Can't show rewarded video
        }
    });
}

For any question or assistance, please contact us at [email protected]

startapp_inapp_sdk_example's People

Contributors

dimanem avatar hadadtomer avatar sofiablaunshtein avatar startapp-sdk avatar tomerhadad avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.