gpt4 book ai didi

android - 在 API 23/Marshmallow 的 onOptionsItemSelected() 中的 recreate() 中出现错误

转载 作者:塔克拉玛干 更新时间:2023-11-02 21:37:31 27 4
gpt4 key购买 nike

我正在尝试让我的应用程序在 API<23 设备上完美运行,使其在 API 23 设备上运行。它在以下场景中崩溃。用户通过选项菜单更改设置。如果他们在菜单选项上缓慢点击(这样就有时间看到突出显示的选项),一切都很好,但如果他们快速点击,应用程序就会崩溃。
我知道这是一种非常奇怪的行为,我花了一些时间试图了解是什么引发了错误。错误发生在 onOptionItemSelected 中的 recreate() 之后。我在 recreate() 之前设置了一个超时来测试该选项是否“已验证”,但这没有用。我只能想到 API 23 中的某种错误,因为它以前与其他 API 一起工作过。这是我的代码 fragment (缩减到最低限度):

@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.menu_item_1:
//... some code goes here
recreate();
return true;
// some other options ..
}
return super.onOptionsItemSelected(item);
}

在创建一个带有空白 Activity 的新项目并在 onOptionsItemSelected() 中添加之后

if (id == R.id.action_settings) {
recreate();
return true;
}

应用仍然崩溃。

这是日志:

10-20 23:12:10.062 3217-3245/? E/Surface: getSlotFromBufferLocked: unknown    buffer: 0xab3d1b80
10-20 23:12:11.050 3217-3245/? E/Surface: getSlotFromBufferLocked: unknown buffer: 0xb4013030
10-20 23:12:11.075 3217-3245/? E/Surface: queueBuffer: error queuing buffer to SurfaceTexture, -19
10-20 23:12:11.075 3217-3245/? E/EGL_emulation: tid 3245: swapBuffers(324): error 0x3003 (EGL_BAD_ALLOC)
10-20 23:12:11.075 3217-3245/? A/OpenGLRenderer: Encountered EGL error 12291 EGL_BAD_ALLOC during rendering
10-20 23:12:11.075 3217-3245/? A/libc: Fatal signal 6 (SIGABRT), code -6 in tid 3245 (RenderThread)

最佳答案

这确实是一个错误。在我报告之后,它已经被谷歌修复了。可以在这里关注:https://code.google.com/p/android/issues/detail?id=195966

同时,我的解决方法是将 recreate() 替换为:

    Intent intent = getIntent();
finish();
startActivity(intent);

但是重新加载不像 recreate() 那样顺利(我可以看到一点闪烁)。

关于android - 在 API 23/Marshmallow 的 onOptionsItemSelected() 中的 recreate() 中出现错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33244845/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com