Send the data in onCreate
but only if savedInstanceState
is null:
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.my_layout);
if(savedInstanceState == null) {
// send data in a background thread
}
}
If the activity is re-created (your case), the savedInstanceState
is not null and it will contain any statefull info you would need to set.