简体   繁体   English

启动画面后的活动

[英]Activity after splash screen

Once my splash screen display for 1000ms I receive an error stating "The application has stopped unexpectedly. Please try again." 一旦我的启动画面显示1000毫秒,我收到一条错误,指出“应用程序已意外停止。请再试一次。” It seems an activity that is supposed to start after the splash screen is not working. 这似乎是一个活动,应该在启动画面不起作用后启动。 before the splash screen, everything worked fine. 在启动画面之前,一切正常。 Logcat shows the following error " E/AndroidRuntime(5480): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.xxxxx.home/com.xxxxx.home.xxxxx}: java.lang.NullPointerException. I beleive the issue is with my Splash Class but cannot pin point where. Any insight would be greatly appreciated. Logcat显示以下错误“E / AndroidRuntime(5480):java.lang.RuntimeException:无法启动活动ComponentInfo {com.xxxxx.home / com.xxxxx.home.xxxxx}:java.lang.NullPointerException。我相信这个问题是我的Splash Class但不能指出哪里。任何见解都将非常感激。

public class Splash extends Activity{ 公共类Splash extends Activity {

private final int SPLASH_DISPLAY_LENGTH = 1000;

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.splash);


    new Handler().postDelayed(new Runnable(){
        @Override
        public void run() {

            Intent openxxxxx = new Intent("com.xxxxx.home.XXXXX");
            startActivity(openxxxxx);

        }
    }, SPLASH_DISPLAY_LENGTH);
}

} }

Here is the complete code you can use this, 这是您可以使用的完整代码,

package com.fsp.slideview;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.MotionEvent;
import android.view.Window;

public class ImageSplashActivity extends Activity {
    /**
     * The thread to process splash screen events
     */
    private Thread mSplashThread;

    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        setContentView(R.layout.splash);

        final ImageSplashActivity sPlashScreen = this;

        mSplashThread = new Thread() {
            @Override
            public void run() {
                try {
                    synchronized (this) {
                        wait(2000);
                    }
                } catch (InterruptedException ex) {
                }

                finish();
                Intent intent = new Intent();
                intent.setClass(sPlashScreen, SlideMainActivity.class);
                startActivity(intent);
            }
        };

        mSplashThread.start();
    }

    @Override
    public boolean onTouchEvent(MotionEvent evt) {
        if (evt.getAction() == MotionEvent.ACTION_DOWN) {
            synchronized (mSplashThread) {
                mSplashThread.notifyAll();
            }
        }
        return true;
    }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM