daily pastebin goal
53%
SHARE
TWEET

Untitled

a guest Feb 13th, 2018 61 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public class CustomActivity extends Activity {
  2.  
  3.     private NativeAdViewAppWall nav_aw;
  4.     private Button showNative;
  5.     private String appKey = "your_app_key";
  6.  
  7.     @Override
  8.     protected void onCreate(Bundle savedInstanceState) {
  9.         super.onCreate(savedInstanceState);
  10.         setContentView(R.layout.activity_custom);
  11.         initializeNativeAds();
  12.     }
  13.  
  14.     private void initializeNativeAds() {
  15.         Appodeal.disableLocationPermissionCheck();
  16.         Appodeal.setAutoCacheNativeIcons(true);
  17.         Appodeal.setAutoCacheNativeMedia(false);
  18.         Appodeal.setTesting(true);
  19.         Appodeal.initialize(this, appKey, Appodeal.NATIVE);
  20.  
  21.         Appodeal.setNativeCallbacks(new NativeCallbacks() {
  22.             @Override
  23.             public void onNativeLoaded() {
  24.                 Log.d("Appodeal", "onNativeLoaded");
  25.             }
  26.  
  27.             @Override
  28.             public void onNativeFailedToLoad() {
  29.                 Log.d("Appodeal", "onNativeFailedToLoad");
  30.             }
  31.  
  32.             @Override
  33.             public void onNativeShown(NativeAd nativeAd) {
  34.                 Log.d("Appodeal", "onNativeShown");
  35.             }
  36.  
  37.             @Override
  38.             public void onNativeClicked(NativeAd nativeAd) {
  39.                 Log.d("Appodeal", "onNativeClicked");
  40.             }
  41.         });
  42.  
  43.         nav_aw = findViewById(R.id.native_ad_view_app_wall);
  44.         showNative = findViewById(R.id.btn_show);
  45.  
  46.         showNative.setOnClickListener(new View.OnClickListener() {
  47.             @Override
  48.             public void onClick(View v) {
  49.                 showNative();
  50.             }
  51.         });
  52.     }
  53.  
  54.     void showNative() {
  55.         if (Appodeal.isLoaded(Appodeal.NATIVE)) {
  56.             NativeAd mNativeAd = Appodeal.getNativeAds(1).get(0);
  57.             nav_aw.setNativeAd(mNativeAd);
  58.         }
  59.     }
  60. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top