0

I have 2 activity when I press the image on 1 activity it launches the 2 activity. Each time when 2 activity launch it triggers the http request and form the table.

It works fine but when i press "back" button and then again start the application and came to the 2 activity.

It doesnt clear the previous data of table and add the data which came from http request. I didnt use a database its just a xml tablelayout.

Simply I just want to start my application from initial state.

I dont want the android system to remember the activity's previous state when I backpressed the whole application.

Please help me on this.

Kailash Dabhi
  • 3,473
  • 1
  • 29
  • 47

3 Answers3

1

In manifest, for second activity write android:noHistory="true", then it won't remember history.

Sankar
  • 1,685
  • 2
  • 16
  • 27
1

then may be i think you should completely close the application on back press so your problem will be solved. this is the code :--

 @Override
 public void onBackPressed() 
 {
    finish();
    android.os.Process.killProcess(android.os.Process.myPid());
 }

this method kills the application and Ofcourse your problem!

0

if i'm getting correct (from your question) , You need to check the views before making http call e.g let us say u have a textview there in table layout, then check like this before making the http call:

   if(getthevalueoftextview!=null){ 

           textview.setText("");
       }
Mohit
  • 2,940
  • 2
  • 24
  • 32
  • its not table its tablelayout.pls help – Kailash Dabhi Aug 29 '12 at 06:08
  • what view have u used to display the form output just set text of that view to empty string do this stuff with in if else statement(see above). Let us say u have a textview to display the name then just assign empty string to that view by calling setText("") on that view – Mohit Aug 29 '12 at 06:13
  • in short tablerow that was previously added by request is not being cleared when i press the back button and so when i again come to the activity it again request the data and added it in table layout with previous rows. getting my point?? – Kailash Dabhi Sep 03 '12 at 04:58