在应用开启时先放一段广告。虽然广告很讨厌,但程序猿也是要恰饭的嘛
1.设置默认加载的Activity为SplashActivity(随便建):
<activity
android:name=".SplashActivity"
android:screenOrientation="portrait"
android:theme="@style/SplashTheme">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
2.SplashActivity:
public class SplashActivity extends BaseActivity<ActivitySplashBinding> {
@Override
public int getLayoutId() {
return R.layout.activity_splash;
}
@Override
public void initView(Bundle savedInstanceState) {
super.initView(savedInstanceState);
start();
}
public void start() {
Handler handler = new Handler();
long waitTime = 2000;
handler.postDelayed(() -> {
MainActivity.actionStart(this);
finish();
}, waitTime);
}
}
效果: CSDN打钱 !!!
然后进入主页:
|