java - 如何避免在后台运行时启动应用程序时显示启动画面?
问题描述
仅在重新启动时显示启动画面,而不是在后台运行时启动应用程序时显示。这是飞溅活动的代码。
public class SplashActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.activity_intro);
Handler handler = new Handler();
handler.postDelayed(() -> {
Intent intent = new Intent(SplashActivity.this, MainActivity.class);
startActivity(intent);
finish();
},2000);
}
}
解决方案
为显示初始屏幕创建新活动。然后在你的 AndroidManifest.xml 中移动
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
从 MainActivity 到您的启动活动标签
推荐阅读
- php - Wordpress - 如何仅显示 10 个用户?
- sockets - 如何在不使用任何 API 的情况下编写我自己的 MQTT 客户端代码
- selenium - 替代已弃用的 Firefox 操作 API
- mysql - MySQL插入忽略重复但因外键错误而失败
- react-native - 如何在 redux-action 中导航?
- rounding - terraform 是否支持数学舍入?
- ios - Linphone linphone_core_iterate 崩溃
- mysql - 在我的 Mac 上安装了 MySQL,并删除了全局 npm、gulp 等。保存 npm 的步骤?
- audio - Google Cloud Text-to-Speech Interface Confusion(如何下载 mp3 文件?)
- java - 为什么这个 java 代码表现出奇怪的行为?