我想将片段实现为启动画面,它会在不到1秒的时间内显示出来,它会用插页式广告取代自己。我想实施Admob建议的展示插页式广告的方式。我想在片段中显示“ App Loading ”屏幕,并在广告准备好时隐藏片段。我是在片段而不是视图中进行的,因为我需要将其作为通用解决方案,然后将其添加到我的其他应用程序中。
答案 0 :(得分:2)
您可以显示片段,并在片段交易后添加
private static int SPLASH_TIME_OUT = 3000;
new Handler().postDelayed(new Runnable() {
/*
* Showing splash screen with a timer. This will be useful when you
* want to show case your app logo / company
*/
@Override
public void run() {
// This method will be executed once the timer is over
// Start your app main activity
Intent i = new Intent(SplashScreen.this, MainActivity.class);
startActivity(i);
// close this activity
finish();
}
}, SPLASH_TIME_OUT);
答案 1 :(得分:2)
在您的非页内广告的onCreate中输入此代码
// This time is in milliseconds
final int SPLASH_TIME_OUT = 3000;
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
// Code to start new activity and finish this one
}
}, SPLASH_TIME_OUT);
答案 2 :(得分:2)
试试此代码
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
// your code here
}
}, TIME_OUT_IN_MILLIS);