Advertisement
Guest User

Untitled

a guest
Apr 24th, 2021
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.29 KB | None | 0 0
  1. public void onCreate(Bundle savedInstanceState) {
  2.         super.onCreate(savedInstanceState);
  3.         getSupportActionBar().hide();
  4.         getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);
  5.         setContentView(R.layout.activity_main);
  6. ///////////////////////////////
  7.                 //MobileAds.initialize(this,"ca-app-pub-3940256099942544/5224354917");
  8.         MobileAds.initialize(this, new OnInitializationCompleteListener() {
  9.             @Override
  10.             public void onInitializationComplete(InitializationStatus initializationStatus) {
  11.                 //RewardedAd.load();
  12.             }
  13.         });
  14.                 AdRequest adRequest = new AdRequest.Builder().build();
  15. //ca-app-pub-6779580915401561/1392653660
  16.         RewardedAd.load(this, "ca-app-pub-3940256099942544/5224354917",
  17.                 adRequest, new RewardedAdLoadCallback(){
  18.                     @Override
  19.                     public void onAdFailedToLoad(@NonNull LoadAdError loadAdError) {
  20.                         // Handle the error.
  21.                         Log.d(TAG, loadAdError.getMessage());
  22.                         mRewardedAd = null;
  23.                     }
  24.  
  25.                     @Override
  26.                     public void onAdLoaded(@NonNull RewardedAd rewardedAd) {
  27.                         mRewardedAd = rewardedAd;
  28.                         Log.d(TAG, "Ad was loaded.");
  29.                     }
  30.                 });
  31.  
  32.         mRewardedAd.setFullScreenContentCallback(new FullScreenContentCallback() {
  33.             @Override
  34.             public void onAdShowedFullScreenContent() {
  35.                 // Called when ad is shown.
  36.                 Log.d(TAG, "Ad was shown.");
  37.                 mRewardedAd = null;
  38.             }
  39.  
  40.             @Override
  41.             public void onAdFailedToShowFullScreenContent(AdError adError) {
  42.                 // Called when ad fails to show.
  43.                 Log.d(TAG, "Ad failed to show.");
  44.             }
  45.  
  46.             @Override
  47.             public void onAdDismissedFullScreenContent() {
  48.                 // Called when ad is dismissed.
  49.                 // Don't forget to set the ad reference to null so you
  50.                 // don't show the ad a second time.
  51.                 Log.d(TAG, "Ad was dismissed.");
  52.             }
  53.         });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement