我正在制作一个应用程序,我必须在其中显示一个欢迎页面仅 5 秒钟,然后重定向到另一个活动。但是,我没有得到我想要的,因为我先得到另一个活动,然后单击模拟器的后退按钮后得到 MainActivity,这是不正确的。那么有人可以帮助我吗?
我正在放置一些代码供您参考,特别是欢迎活动和清单代码:
public class Welcome extends Activity
{
private Runnable runnable;
private static final String TAG="Welcome";
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
runnable=new Runnable() {
public void run() {
try
{
Log.v(TAG,"Going to sleep...");
Thread.sleep(3000);
Log.v(TAG,"Going to wake up...");
}
catch(Exception e)
{
e.printStackTrace();
}
}
};
try
{
Thread t=new Thread(null,runnable);
t.start();
Intent i=new Intent(this,TabSample.class);
startActivity(i);
}
catch(Exception e)
{
}
}
}
AndroidManifest.xml
<activity
android:name=".Welcome"
android:label="Restaurant Application" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".TabSample"></
主要的.xml
<ImageView
android:id="@+id/imageView1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_alignParentRight="true"
android:src="@drawable/home" />