如何关闭活动而不再次显示启动屏幕?
我正在制作一个启动屏幕,需要帮助关闭此活动,因此如果用户按下“返回”按钮,他们将返回主屏幕,而不是启动屏幕...
package com.Sosotech;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
public class Splashscrn extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.splashscrn);
Handler x = new Handler();
x.postDelayed(new SplashHandler(), 5000);
}
class SplashHandler implements Runnable {
public void run() {
startActivity(new Intent(getApplication(), Main.class));
}
}
}
PS:我只想知道是否可以使每次恢复应用程序时都会出现启动屏幕。我不会实施这个,我只是想知道它会如何完成。
I am making a splash screen and need help closing this activity so if a user presses the 'BACK' button they go back to the home screen, NOT the splash screen...
package com.Sosotech;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
public class Splashscrn extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.splashscrn);
Handler x = new Handler();
x.postDelayed(new SplashHandler(), 5000);
}
class SplashHandler implements Runnable {
public void run() {
startActivity(new Intent(getApplication(), Main.class));
}
}
}
PS: I just want to know if it is possible to make the splash screen come up every time the app is resumed. I will not be implementing this, I just wondered how it would be done.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
要关闭活动:
为了您的 PS
将活动设置为主要的启动活动,并在清单中将clearTaskOnLaunch 设置为 true。
To close the activity:
For your PS
Set the activity as your main, launching activity and set clearTaskOnLaunch to true in the manifest.
使用 finish() 作为:
startActivity(new Intent(getApplicationContext(), Main.class));
结束();
use finish() as:
startActivity(new Intent(getApplicationContext(), Main.class));
finish();