Boy, have headphones changed in the last few years. From something that was simply a black wire that split into 2 earpieces, they’ve morphed into a plethora of options and varieties with an assortment of buttons, sliders, and connections, each meant to make your music experience a little bit more convenient. And with the addition of OEMs designing and creating earphones for specific device models, compatibility issues may arise when you plug them into a new device for the first time.
For Sony Xperia Z Ultra users, XDA Forum Member Pannam offers up a potential fix for issues with headphone / device incompatibility where certain buttons do not work on some devices. The fix basically consists of a simple tweak of a system value labelled headsethook. But first, you must install the provided keytest.apk and with it, find the numerical scancode of your headset. Once that’s done, simply change the headsethook value to the scancode of your headset. You then change the headsetscancode to the original headsethook value, and install a third party headset app.
Although claimed to work with only the Xperia Z Ultra, it is likely that this will also work on other Xperia devices, as well as other Android devices in general. That said, always make a backup of the original files just in case things do not work out and you need to revert back to your previous settings. To find out more, visit the original thread.