I want to load Interstitial AdMob after 5 second, after the Activity started, in another Thread
. Is this code right, or I'm duplicating Runnable
s? Is there a better way?
Handler handler;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setActivityImmersiveMode();
setContentView(R.layout.activity_normal_mode);
// loading ads
handler = new Handler();
Runnable runnable = new Runnable() {
@Override
public void run() {
handler.postDelayed(new Runnable() {
@Override
public void run() {
loadInterstitialAd();
}
}, 5000);
}
};
Thread thread = new Thread(runnable);
thread.setName("AdThread");
thread.start();
}