【发布时间】:2015-09-08 07:25:59
【问题描述】:
当我最小化时,对象的分数和位置等数据会被重置。当我锁定屏幕时,应用程序会重新启动。有没有办法保存所有对象数据以使其恢复后的位置和分数相同?以及如何使块屏按钮(与等待锁屏相同)不会使应用重新启动。是否可以通过应用程序禁用自动锁屏?
抱歉,问的太多了,我是新来的,在其他问题中找不到我想要的。
这是我的 Activity 类:
`public class Home 扩展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);
}
}`
【问题讨论】:
标签: android android-activity surfaceview onresume onpause