Answer the question
In order to leave comments, you need to log in
The function of the button without the Internet does not work, what's the problem?
Hello everyone, I wanted to add interstitial advertising, when you click on a button. When the Internet is on, everything works, I press the button, the ad comes out, then activity2 starts.
but when the internet is off. The button does not work at all and activity2 does not start
mInterstitialAd.setAdListener(new AdListener() {
@Override
public void onAdClosed() {
// Load the next interstitial.
mInterstitialAd.loadAd(new AdRequest.Builder().build());
startActivity(new Intent(activity.this, activity2.class));
}
});
Что можно сюда прописать? Что бы когда нету интернета, при нажатии запускался activity2.class
Button homeBut = (Button)findViewById(R.id.goHomeButt);
homeBut .setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (mInterstitialAd.isLoaded()) {
mInterstitialAd.show();
} else {
// сюда пробовал прописать startActivity(new Intent(activity.this, activity2.class));
// Но межстраничная реклама перестала запускаться
Log.d("TAG", "The interstitial wasn't loaded yet.");
}
}
});
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question