Guys, I asked a question, but I made it up incorrectly ... There is an application that determines my location and sends data to a remote Mysql database. I put logs on all actions and monitor the behavior of the application. There are 2 buttons in the application. When you click, they will receive data and send them at intervals to the database and become invisible. Here is an example.

 final TimerTask timerTask = new TimerTask() { @Override public void run() { int i=0; i++; System.out.println("Request N +" +i); Sender s=new Sender(MainActivity.this,urlAddress,lat,lot); s.execute(); } }; final Timer timer =new Timer(); saveBtn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { //timer.scheduleAtFixedRate(timerTask,0,3000); timer.scheduleAtFixedRate(timerTask,0,8000); saveBtn.setVisibility(View.INVISIBLE); } }); 

The second button cancels the action of 1 button and makes it visible

  removeBtn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { try { timer.cancel(); }catch (Exception e){ Toast.makeText(MainActivity.this,e +"", Toast.LENGTH_SHORT).show(); } saveBtn.setVisibility(View.VISIBLE); } }); } 

But if I roll up and deploy the application then

1) Invisible button becomes visible

2) I can not undo the action of 1 button As if I didn’t deploy the application but started it again and lost control of the old action. Please Help. Thanks!

    1 answer 1

    It is necessary to save the state of the application through the object Bundle . After activating the application, the parameters that you saved in the Bundle can be used to restore the state of the application.

    • Thank you Denis! Very gracious to YOU! - elik