知道如何暂停~resume/stop~重新启动应用程序吗?禁用自动锁屏?

Any idead how to pause~resume/stop~restart the application? Disable auto lockscreen?

当我最小化时,物体的得分和位置等数据被重置。当我锁定屏幕时,应用程序会重新启动。有没有办法保存所有对象的数据,使它们在恢复后的位置和分数相同?以及我如何使块屏幕按钮(与等待锁屏相同)不让应用程序重新启动。是否可以通过应用程序禁用自动锁屏?

不好意思问多了,我是新来的,其他问题没找到我想要的

这是我的 Activity class:

`public class 主页扩展 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);
}

}`

我认为你应该使用 saveInstanceState 和 restoreInstanceState。

结帐 "Save Your Activity State" http://developer.android.com/training/basics/activity-lifecycle/recreating.html#SaveState