I am trying to build my application, working perfectly on API <23 devices, working with API 23 device.
Basically, when a user changes a setting through the options menu, activity is recreated using the rereate () function. Now, if I slowly click on the menu option (so that I have time to see the highlighted option), everything is fine, but if I touch briefly, the application will crash.
I know this is strange behavior, and it was hard for me to understand what caused the error. I set a timeout before recreating (), so maybe the option is "checked", but it did not work. I can only think of some kind of error in API 23 because it used to work with other APIs. Here is a snippet of my code (nothing special):
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.menu_item_1:
and logcat:
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)
Any help or advice would be greatly appreciated.
UPDATE I definitely think there is an error in API> 23. After creating a new project with empty activity and just adding inside onOptionsItemSelected ()
if (id == R.id.action_settings) { recreate(); return true; }
application still crashes.
So my workaround :
Intent intent = getIntent(); finish(); startActivity(intent);
But the reboot is not as smooth as when recreating () (I see a little blinking).
source share