-3

我遇到了这个问题..基本上这是创建启动画面的简单方法,但是在加载启动画面后我想加载主窗体,但在这里我遇到了这个问题…………我已将活动添加到清单也......这是我的java代码

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
        setContentView(R.layout.splash);
        Thread logotimer=new Thread(){
            public void run()
            {
            try
            {
                int timer=0;
                while(timer<5000)
                {
                    sleep(100);
                    timer=timer+100;

                }
                startActivity(new Intent("splashscreen.app.test.CLEARSCREEN"));
            } catch (InterruptedException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            finally
            {
                finish();
            }

            }
        };
        logotimer.start();

    }
}

这是我包含的清单活动

 <application
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name" >
    <activity
        android:name=".SplashscreenActivity"
        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=".menu"
        android:label="@string/app_name">
        <intent-filter>
            <action android:name="android.intent.action.CLEARSCREEN" />

            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>
    </activity>
</application>
4

2 回答 2

1

将此行更改startActivity(new Intent("splashscreen.app.test.CLEARSCREEN"));

startActivity(new Intent(YourActivity.this,SecondActivity.class));

供您参考,以后不要使用 Activity 或类名作为菜单。

在你的明显使用中,

<activity 
        android:name=".menu"
        android:label="@string/app_name">
        <intent-filter>
            <action android:name="android.intent.action.VIEW" />

            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>
    </activity>

或者

<activity 
        android:name=".menu"/>

请参阅本教程制作启动画面http://www.codeproject.com/Articles/113831/An-Advanced-Splash-Screen-for-Android-App

于 2012-07-07T07:57:36.553 回答
0

用这个:

<application
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name" >
    <activity
        android:name=".SplashscreenActivity"
        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=".menu"
        android:label="@string/app_name">
    </activity>
</application>

和:

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.splash);
    Thread logotimer=new Thread(){
        public void run()
        {
        try
        {
            int timer=0;
            while(timer<5000)
            {
                sleep(100);
                timer=timer+100;

            }
            Intent intent = new Intent(YourSplashActivityName.this,TagetActivityName.class);
            startActivity(intent);
        } catch (InterruptedException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        finally
        {
            finish();
        }

        }
    };
    logotimer.start();

}
于 2012-07-07T07:54:49.963 回答