我遇到了一个问题,即在将启动画面包含到应用程序后应用程序无法加载。这是 SplashScreen.java 和 Manifest 文件的代码。我不确定我错过了什么。我已经检查了好几次,但无法发现错误。我已经浏览过类似的帖子,但可以找到答案。请帮忙
public class SplashScreen extends Activity {
private long ms=0;
private long splashTime=2000;
private boolean splashActive = true;
private boolean paused=false;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.splash);
Thread mythread = new Thread() {
public void run() {
try {
while (splashActive && ms < splashTime) {
if(!paused)
ms=ms+100;
sleep(100);
}
} catch(Exception e) {}
finally {
Intent intent = new Intent(SplashScreen.this, TotalControl.class);
startActivity(intent);
}
}
};
mythread.start();
}
清单文件如下
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.tvganesh.totalcontrol.SplashScreen"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.tvganesh.totalcontrol.TotalControl"
android:label="@string/app_name" >
</activity>
</application>
在它显示的启动画面之后,它应该切换到 TotalControl.class。但是我收到消息“应用程序意外停止”
你能告诉我我错过了什么吗?