简体   繁体   English

恢复了上一个活动并完成了上一个活动

[英]Restored the last activity and finish the previous activity

how would i restore my last activity even when the user close the application and finish the previous one. 即使用户关闭应用程序并完成上一个活动,我如何恢复我的上一个活动。 What i mean is that, when the user reopen the application that has been close he will still see the last activity and when he press the back button of the emulator he would never see the the previous activity it will direct to the home page of the emulator (it is something like the previous activity will finish so it will never come back to the previous activity). 我的意思是,当用户重新打开已关闭的应用程序时,他仍然会看到上一个活动,而当他按模拟器的“后退”按钮时,他将永远不会看到上一个活动,它将直接指向该活动的主页。模拟器(类似于上一个活动将完成,因此它将永远不会回到上一个活动)。 please i need a help, please explain it very clear, im sorry i am new in android. 请我需要帮助,请解释清楚,对不起,我是android新手。 one more request if it can, could you please explain step by step. 如果可以的话,请再提出一个要求。

This is my 1st activity 这是我的第一次活动

public class MainActivity extends Activity {

public EditText txt_Emp, txt_Email, txt_Security;
public ImageButton btn_Submit, btn_Generate, btn_Resend;
final Context context = this;

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


     txt_Emp = (EditText) findViewById(R.id.txt_emp);
     txt_Email = (EditText) findViewById(R.id.txt_email);
     txt_Security = (EditText) findViewById(R.id.txt_code);
     btn_Submit = (ImageButton) findViewById(R.id.btn_submit);
     btn_Generate = (ImageButton) findViewById(R.id.btn_generate);
     btn_Resend = (ImageButton) findViewById(R.id.btn_resend);


     btn_Generate.setOnClickListener(new OnClickListener() {
     @Override
     public void onClick(View v) 
     {
         String email = txt_Email.getText().toString();
         String employee = txt_Emp.getText().toString();

         //Hashcode
                         //this will get the hashcode


            //SENDING AN EMAIL
                              // this is for sending an email containing the hashcode


    btn_Submit.setOnClickListener(new OnClickListener() {

    @Override
    public void onClick(View v) {
        //this will proceed to the next activity if the code is correct
            }   
                         }

This is my 2nd activity 这是我的第二次活动

public class WelcomeActivity extends Activity { 公共类WelcomeActivity扩展Activity {

TextView txtWelcome;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_welcome);

    quit = (Button) findViewById(R.id.button1);

    quit.setOnClickListener(new OnClickListener() {
    public void onClick(View v) {

               //this button will direct to the 1st activity.

        }
        });
       }

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.welcome, menu);
    return true;
}
}

I want it that if the user did not click the user he would stay on the second activity even if he close the apps and if he click the return in emulator the apps will never gets back to the first activity. 我想要的是,如果用户没有单击该用户,即使他关闭了应用程序,他也将继续进行第二个活动,并且如果他单击模拟器中的return,则这些应用程序将永远不会回到第一个活动。 and i dont have any idea. 而且我没有任何想法。 Thank you very much. 非常感谢你。

我通过使用共享首选项解决了这个问题。

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

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