Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/217.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
Java Android Studio应用程序崩溃_Java_Android_Crash - Fatal编程技术网

Java Android Studio应用程序崩溃

Java Android Studio应用程序崩溃,java,android,crash,Java,Android,Crash,我在Android Studio上制作的应用程序有问题。我不知道为什么,但是在启动屏幕之后,应用程序崩溃了。我希望活动“Accueil”在启动屏幕后打开。上周它工作得很好,现在不再是了。我什么也没碰。我向您展示清单和.java文件 Splashscreen.java: import android.app.Activity; import android.content.Intent; import android.graphics.PixelFormat; import android.os.

我在Android Studio上制作的应用程序有问题。我不知道为什么,但是在启动屏幕之后,应用程序崩溃了。我希望活动“Accueil”在启动屏幕后打开。上周它工作得很好,现在不再是了。我什么也没碰。我向您展示清单和
.java
文件

Splashscreen.java:

import android.app.Activity;
import android.content.Intent;
import android.graphics.PixelFormat;
import android.os.Bundle;
import android.view.Window;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.ImageView;
import android.widget.LinearLayout;

public class Splashscreen extends Activity {
    public void onAttachedToWindow() {
        super.onAttachedToWindow();
        Window window = getWindow();
        window.setFormat(PixelFormat.RGBA_8888);
    }

    Thread splashTread;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_splashscreen);
        StartAnimations();
        Thread loading = new Thread() {
            public void run() {
                try {
                    sleep(5000);
                    Intent main = new Intent(Splashscreen.this,Menu.class);
                    startActivity(main);
                    finish();
                } catch (Exception e) {
                    e.printStackTrace();
                } finally {
                    finish();
                }
            }
        };

        loading.start();
    }

    private void StartAnimations() {
        Animation anim = AnimationUtils.loadAnimation(this, R.anim.alpha);
        anim.reset();
        LinearLayout l = (LinearLayout) findViewById(R.id.lin_lay);
        l.clearAnimation();
        l.startAnimation(anim);
        anim = AnimationUtils.loadAnimation(this, R.anim.rotate);
        anim.reset();
        ImageView iv = (ImageView) findViewById(R.id.splash);
        iv.clearAnimation();
        iv.startAnimation(anim);
        splashTread = new Thread() {
            @Override
            public void run() {
                try {
                    int waited = 0;

                    while (waited < 3500) {
                        sleep(100);
                        waited += 100;
                    }

                    Intent intent = new Intent(Splashscreen.this,Menu.class);
                    startActivity(intent);
                    finish();
                } catch (InterruptedException e) {

                }
            }
        };
    }
}
这样做

Intent main = new Intent(Splashscreen.this, Accueil.class);
                    startActivity(main);
                     finish();
而不是

Intent main = new Intent(Splashscreen.this, Menu.class);
                startActivity(main);
                finish();
您甚至没有在清单中提到菜单活动。

这是您的错误:

Intent main = new   Intent(Splashscreen.this,Menu.class); 
应该是:

Intent main = new   Intent(Splashscreen.this, Accueil.class);

我认为你的应用程序崩溃可能是因为两个原因

  • 没有名为“菜单”的活动
  • 清单文件中未提及菜单活动
  • 如果你想打开“Accueil”活动,那么用下面的方式写下你的意图

    Intent openAccueil = new   Intent(Splashscreen.this,Menu.class);
    startActivity(openAccueil);
    

    请把你的崩溃日志。也不要把UI线程放在睡眠状态。
    Intent main = new   Intent(Splashscreen.this, Accueil.class);
    
    Intent openAccueil = new   Intent(Splashscreen.this,Menu.class);
    startActivity(openAccueil);