Loadeed
Loadeed

Reputation: 567

Android ICS back button

I developed an application on Android 2.3.3. When I click a button in application, I open next Activity via Intent and populate Linear Layout with data in onCreate method. Then I go to the next activity. When I click back button, previous Activity is loaded with all the data. My application works fine on Android 2.3.5, but when I tested it on Android 4.0, the previous activity is missing data.

I also implemented back button action. I call this.finish() on Activity.

Upvotes: 0

Views: 717

Answers (1)

jimmithy
jimmithy

Reputation: 6380

I would recommend looking into saving the instance state of your application. This can be done by using a combination of onSaveInstanceState and onRestoreInstanceState. This way all data is retained by the Activity.

@Override        
protected void onSaveInstanceState(Bundle savedInstanceState) {
   super.onSaveInstanceState(savedInstanceState);            
   savedInstanceState.putInt("data", a);
}

@Override    
protected void onRestoreInstanceState(Bundle savedInstanceState) {
    super.onRestoreInstanceState(savedInstanceState);     
    a= savedInstanceState.getInt ("data");   
} 

Upvotes: 1

Related Questions