0

I have create an Android application (functional).

My problem is when people use advanced task killer (what is useless), all my variables are wiped but the application is not to kill completely, it is started again but it misses all the data. I would like that the application is to kill completely and starts again completely.

Does somebody have an idea?

benji2092
  • 53
  • 1
  • 8

1 Answers1

2

why don't you modify your application that handles these kind of situations by saving all your data and restoring it in methods onSaveInstanceState and onRestoreInstanceState ?

Edit:

@Override
public void onSaveInstanceState(Bundle savedInstanceState) {
  super.onSaveInstanceState(savedInstanceState);
  // Save UI state changes to the savedInstanceState.
  // This bundle will be passed to onCreate if the process is
  // killed and restarted.
  savedInstanceState.putBoolean("MyBoolean", true);
  savedInstanceState.putDouble("myDouble", 1.9);
  savedInstanceState.putInt("MyInt", 1);
  savedInstanceState.putString("MyString", "Welcome back to Android");
  // etc.
}

@Override
public void onRestoreInstanceState(Bundle savedInstanceState) {
  super.onRestoreInstanceState(savedInstanceState);
  // Restore UI state from the savedInstanceState.
  // This bundle has also been passed to onCreate.
  boolean myBoolean = savedInstanceState.getBoolean("MyBoolean");
  double myDouble = savedInstanceState.getDouble("myDouble");
  int myInt = savedInstanceState.getInt("MyInt");
  String myString = savedInstanceState.getString("MyString");
}
Buda Gavril
  • 21,409
  • 40
  • 127
  • 196