android - 飞溅后未显示主要活动
问题描述
这是我的代码。启动屏幕后主要活动不会运行,并且没有出现错误。它是一个带有导航抽屉的选项卡式活动。可能是什么问题?我试了几次。我在应用程序中尝试了不同的活动以成功运行,但它不适用于主要活动。请帮帮我。
====
闪屏
package com.mohanadmarket.myapplication50
import android.content.Intent
import android.support.v7.app.AppCompatActivity
import android.os.Bundle
import java.util.*
class SplashActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_splash)
Timer().schedule(object : TimerTask(){
override fun run() {
val intent= Intent(this@SplashActivity,MainActivity::class.java)
startActivity(intent)
finish()
}
},5000L)
}
}
主要节日
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.mohanadmarket.myapplication50">
<application
android:allowBackup="true"
android:icon="@mipmap/sudacars_icon"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity
android:name=".SplashActivity"
android:label="@string/app_name"
android:theme="@style/AppTheme.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:launchMode="singleInstance" />
</application>
</manifest>
请告诉我怎么做
谢谢!!
解决方案
你的代码看起来不错。但另一种解决方案是使用Handler
:
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
startActivity(new Intent(SplashActivity.this, MainActivity.class));
}
}, 5000);
推荐阅读
- php - Algolia PHP 客户端使用哪个 TLS 版本?
- mongodb - Mongodb 副本集:“infoMessage”:“找不到要同步的成员”
- cs50 - cs50 潮人 lock_paiors 功能问题
- android - 构建 apk 时遇到问题,合并 dex 档案时出错:
- android - 如何在相同数据类型的房间持久性库中存储两个表?
- java - 我如何在 vs 代码中调试用 java 编写的 docker 容器(风暴爬虫)?
- docker - 从集群外部 ssh 到 kubernetes pod,而在 pod 中没有运行 OpenSSH
- r - 我可以从 Shiny 的列表中创建一堆反应式输入-输出对吗?
- docusignapi - 在尝试获取docusign的访问令牌时获得(400)错误请求响应
- oracle - 获取 Oracle 中当前视图的所有者