我正在編寫一個包含啓動畫面的新應用程序。 我已經完成了,它都很好。在我再次打開android studio來處理導航欄之後,我嘗試運行應用程序來查看結果,但應用程序在啓動屏幕顯示後停止並崩潰。我的Android應用程序在啓動畫面後停止響應
這是主類
package com.example.computer.bsinfoshop;
public class Main extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
}
,這是類OD閃屏
package com.example.computer.bsinfoshop;
import android.graphics.Typeface;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.content.Intent;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;
public class Screen extends AppCompatActivity {
TextView tv;
ImageView img;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_screen);
tv = (TextView)findViewById(R.id.textView);
img = (ImageView)findViewById(R.id.imageView);
Typeface font = Typeface.createFromAsset(getAssets(),"fonts/Satisfy-Regular.ttf");
tv.setTypeface(font);
img.setImageResource(R.drawable.rsz_2rsz_img);
Thread timerThread = new Thread(){
public void run(){
try
{
sleep(3700);
}
catch(InterruptedException e)
{
e.printStackTrace();
}
finally {
Intent intent = new Intent(Screen.this , Main.class);
startActivity(intent);
}
}
};
timerThread.start();
}
@Override
protected void onPause() {
super.onPause();
finish();
}
}
,並在這些地方我認爲是問題
清單文件
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.computer.bsinfoshop">
<application
android:allowBackup="true"
android:icon="@drawable/logo"
android:label="@string/app_name">
<activity
android:name=".Screen"
android:theme="@style/App">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".Information"
android:label="Information"
android:theme="@style/AppTheme">
</activity>
<activity
android:name="com.example.computer.bsinfoshop.Main"
android:theme="@style/AppTheme">
</activity>
</application>
</manifest>
我只想知道我的代碼中存在什麼問題,我該如何解決這個問題。謝謝^^
*「...但是在啓動畫面顯示後應用程序停止並崩潰」*發生這種情況並且您需要幫助時,您需要發佈您的堆棧跟蹤以便我們可以看到錯誤 – codeMagic