When I minimize, the data like score and position of objects are reset. When I lock the screen the app is restarted. Is there a way to save all objects data to make their positions and score be the same after resume? And how I can make the blockscreen button(same as wait for lockscreen) dont make the app restart. Is it possible to disable the auto lockscreen through the application?
Sorry if asking too much, I'm new here and I couldn't find what I want in other questions.
Here is my Activity class:
`public class Home extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(new GamePanel(this));//GamePanel is the SurfaceView
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.menu_home, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
//noinspection SimplifiableIfStatement
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
}`
I think you should go with saveInstanceState and restoreInstanceState.
Checkout "Save Your Activity State" at http://developer.android.com/training/basics/activity-lifecycle/recreating.html#SaveState