11
11
import android .view .View ;
12
12
import android .widget .ImageView ;
13
13
import android .widget .LinearLayout ;
14
+ import android .widget .RelativeLayout ;
14
15
import android .widget .TextView ;
15
16
import android .widget .Toast ;
16
17
43
44
import com .unity3d .services .banners .BannerView ;
44
45
import com .unity3d .services .banners .UnityBannerSize ;
45
46
46
- public class MainActivity extends AppCompatActivity implements IUnityAdsInitializationListener {
47
+ public class MainActivity extends AppCompatActivity implements IUnityAdsInitializationListener , BannerView . IListener {
47
48
48
49
private ImageView ivRound , ivInfo ;
49
50
private LinearProgressIndicator progressBar ;
@@ -61,6 +62,9 @@ public class MainActivity extends AppCompatActivity implements IUnityAdsInitiali
61
62
public static boolean downloadFroze = false ;
62
63
private boolean isInterstitialLoaded = false ;
63
64
65
+ BannerView topBanner ;
66
+ RelativeLayout topBannerView ;
67
+
64
68
@ Override
65
69
protected void onCreate (Bundle savedInstanceState ) {
66
70
super .onCreate (savedInstanceState );
@@ -85,6 +89,18 @@ protected void onCreate(Bundle savedInstanceState) {
85
89
requestPermissionsIfNeeded ();
86
90
}
87
91
92
+ void loadBanner (){
93
+ topBanner = new BannerView (this , "Banner_Android" , new UnityBannerSize (320 , 50 ));
94
+ // Set the listener for banner lifcycle events:
95
+ topBanner .setListener (this );
96
+ // Request a banner ad:
97
+ topBanner .load ();
98
+ // Get the banner view:
99
+ topBannerView = findViewById (R .id .topBanner );
100
+ // Associate the banner view object with the banner view:
101
+ topBannerView .addView (topBanner );
102
+ }
103
+
88
104
private void initializeUI () {
89
105
layoutTitle = findViewById (R .id .layout_title );
90
106
layoutFollow = findViewById (R .id .layout_follow );
@@ -173,12 +189,7 @@ private void startAction() {
173
189
ivRound .setImageResource (hoverImageResource );
174
190
AnimationUtils .scaleImageView (ivRound , R .dimen .image_original_width , -20 );
175
191
176
- if (AppUtils .isInternetAvailable ()){
177
- checkForUpdate ();
178
- }else {
179
- Toast .makeText (this , "No internet connection" , Toast .LENGTH_LONG ).show ();
180
- videoURL = "" ;
181
- }
192
+ checkForUpdate ();
182
193
183
194
}
184
195
@@ -342,6 +353,7 @@ public void onBackPressed() {
342
353
343
354
@ Override
344
355
public void onInitializationComplete () {
356
+ loadBanner ();
345
357
loadInterstitialAd ();
346
358
}
347
359
@@ -372,4 +384,24 @@ public void onUnityAdsFailedToLoad(String placementId, UnityAds.UnityAdsLoadErro
372
384
Log .e ("UnityAds" , "Unity Ads not initialized yet" );
373
385
}
374
386
}
387
+
388
+ @ Override
389
+ public void onBannerLoaded (BannerView bannerAdView ) {
390
+ Log .d ("UnityAds" , "Banner Loaded" );
391
+ }
392
+
393
+ @ Override
394
+ public void onBannerClick (BannerView bannerAdView ) {
395
+
396
+ }
397
+
398
+ @ Override
399
+ public void onBannerFailedToLoad (BannerView bannerAdView , BannerErrorInfo errorInfo ) {
400
+ Log .d ("UnityAds" , "Banner Failed To Load" );
401
+ }
402
+
403
+ @ Override
404
+ public void onBannerLeftApplication (BannerView bannerView ) {
405
+
406
+ }
375
407
}
0 commit comments