Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/date/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 应用程序开始时的启动屏幕_Android - Fatal编程技术网

Android 应用程序开始时的启动屏幕

Android 应用程序开始时的启动屏幕,android,Android,我需要一些帮助。我的应用程序有问题。我想在开头放一个闪屏。我以前做过。我已经在一个新项目中完美地完成了代码、布局和所有工作!当我将代码放在手机上运行,并将布局放在应用程序中时,应用程序运行完美,没有任何错误。但当我在手机上打开它时,它会停止,而它不会打开它!!!你能建议点什么吗 my android manifest.xml: android:name=".activities.SplashScreenActivity" android:label="@strin

我需要一些帮助。我的应用程序有问题。我想在开头放一个闪屏。我以前做过。我已经在一个新项目中完美地完成了代码、布局和所有工作!当我将代码放在手机上运行,并将布局放在应用程序中时,应用程序运行完美,没有任何错误。但当我在手机上打开它时,它会停止,而它不会打开它!!!你能建议点什么吗

my android manifest.xml:

        android:name=".activities.SplashScreenActivity"
        android:label="@string/splash">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
android:name=“.activities.SplashScreenActivity”
android:label=“@string/splash”>

假设您想从SplashScreenActivity启动主活动

在SplashScreenActivity的onCreate()中:


前两行通过Intent启动主活动,第三行终止SplashScreenActivity,因此您无法从MainActivity返回。

显示错误日志inf o。我在android studio没有任何错误我的问题在我的手机上我的应用程序在我的手机上打开时运行正常它崩溃了它没有打开!!我试着在一个新项目中修复我的闪屏,ant在我的手机上运行它,它工作完美,不会崩溃!!意向意向=新意向(SplashScreenActivity.this,LoginActivity.class);星触觉(意向);SplashScreenActivity.this.finish();这是我的代码登录活动是我想在启动screenSplashScreenActivity之后打开的下一个布局。this.finish();是多余的。只需使用finish();除非你在一个内部类中。如果我们看到你的SplashScreenActivity代码,那会容易得多。
public class SplashScreenActivity extends AppCompatActivity {
private  int SLEEP_TIMER = 3;
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    requestWindowFeature(Window.FEATURE_NO_TITLE);
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);

    setContentView(R.layout.activity_splash_screen);

    View imageView = findViewById(R.id.imageView);

    Animation animation = AnimationUtils.loadAnimation(getApplicationContext(),R.anim.fade);

    imageView.startAnimation(animation);
    getSupportActionBar().hide();
    LogoLauncher logoLauncher = new LogoLauncher();
    logoLauncher.start();


}

private class LogoLauncher extends Thread {
    public void run() {
        try {
            sleep(1000  * SLEEP_TIMER);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

        Intent intent = new Intent(SplashScreenActivity.this,LoginActivity.class);
        startActivity(intent);
        SplashScreenActivity.this.finish();
    }
}
public class SplashScreenActivity extends AppCompatActivity {
private  int SLEEP_TIMER = 3;
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    requestWindowFeature(Window.FEATURE_NO_TITLE);
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);

    setContentView(R.layout.activity_splash_screen);

    View imageView = findViewById(R.id.imageView);

    Animation animation = AnimationUtils.loadAnimation(getApplicationContext(),R.anim.fade);

    imageView.startAnimation(animation);
    getSupportActionBar().hide();
    LogoLauncher logoLauncher = new LogoLauncher();
    logoLauncher.start();


}

private class LogoLauncher extends Thread {
    public void run() {
        try {
            sleep(1000  * SLEEP_TIMER);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

        Intent intent = new Intent(SplashScreenActivity.this,LoginActivity.class);
        startActivity(intent);
        SplashScreenActivity.this.finish();
    }
}