在Android的我如何检查是否和什么其他的活动都被留在堆栈上打开?堆栈、其他的、Android

由网友(萌妹子的世界你不懂)分享简介:基本上我想要的if语句象下面这样做的,但我不知道怎么办。Basically I want to do an if statement like below, but I don't know how.if (Android_Classes_Left_Open){Intent a = new Intent(Splas...

基本上我想要的if语句象下面这样做的,但我不知道怎么办。

Basically I want to do an if statement like below, but I don't know how.

if (Android_Classes_Left_Open){
    Intent a = new Intent(SplashScreen.this, 2ndtoTopElement.class);
    startActivity(a);
} else {
    Intent a = new Intent(SplashScreen.this, Other.class);
    startActivity(a);
}

我的闪屏code到目前为止:

My SplashScreen code so far:

public class SplashScreen extends Activity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.splash);

        new Handler().postDelayed(new Runnable() {
            @Override
            public void run() {
                Intent i = new Intent(SplashScreen.this, First.class);
                startActivity(i);

                finish();
            }
        }, 3000);
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.splash, menu);
        return true;
    }
}

这样做的目的是,如果用户移动应用到他们然后返回到他们的最近打开的活动,而不是每次都从头开始该应用程序的背景。我怎样才能做到这一点?

The purpose of this is, if the user moves the application into the background they are then returned to their most recently opened activity rather than starting the application from scratch each time. How can I achieve this?

推荐答案

您的解决方案是,只要你在任何新的活动进入了....

your solution is that whenever you entered in any new activity....

1)你必须保存在共享preferance该活动的名称(在同一个键),你必须在onResume执行的每项活动或BaseActivity这个事情()。

1.) You have to save the name of this activity in shared preferance(on same key) you have to perform this things in onResume() of every activity or your BaseActivity.

2。)在启动画面的每一次,你必须检查这个活动的名称,并通过它在你的意图。

2.) At the every time of splash screen you have to check the name of this activity and pass it in your intent.

让你做你的闪屏后,每次都会获得最后一个打开的活动。

so you get the last open activity each time after your splash screen done.

阅读全文

相关推荐

最新文章