1

I hope you can help me, I am starting with UnityAds, I have an application on Android Studio (Java) where the SplashActivity has a button.

What I want is that, after pressing the button, the UnityAds interstitial is shown and when the ad ends, the MainActivity is shown.

The code I made shows the interstitial after the button but I don't know how to make it open the next activity to the MainActivity because after the interstitial it returns to the SplashActivity

public class SplashActivity extends AppCompatActivity {

String GameID = "123456";
String adUnitId = "Interstitial";
Boolean TestMode = true;


@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_intro_uno);


    //iniciador Unity
    UnityAds.initialize(SplashActivity.this, GameID, TestMode, new IUnityAdsInitializationListener() {
        @Override
        public void onInitializationComplete() {
        }

        @Override
        public void onInitializationFailed(UnityAds.UnityAdsInitializationError unityAdsInitializationError, String s) {
        }
    });
    //iniciador Unity

}

public void onClick(View view) {

     IUnityAdsShowListener iUnityAdsShowListener = new IUnityAdsShowListener() {
        @Override
        public void onUnityAdsShowFailure(String s, UnityAds.UnityAdsShowError unityAdsShowError, String s1) {

        }

        @Override
        public void onUnityAdsShowStart(String s) {
            UnityAds.load(adUnitId);
            UnityAds.show(SplashActivity.this,adUnitId);
        }

        @Override
        public void onUnityAdsShowClick(String s) {
        }

        @Override
        public void onUnityAdsShowComplete(String s, UnityAds.UnityAdsShowCompletionState unityAdsShowCompletionState) {

        }

    };

    UnityAds.load(adUnitId);
    UnityAds.show(SplashActivity.this,adUnitId);
}

}

1 Answers1

0

Just add

startActivity(new Intent(MainActivity.this,MainActivity2.class));

In onUnityAdsShowComplete method ---In this above line MainActivity is the Current Activity and MainActivity2 is the second Activity

Elikill58
  • 4,050
  • 24
  • 23
  • 45