Recently in project I faced challenge of resizing VirtualDisplay
"on flight". So the use case is :
- Start stream
- In undetermined period of stream there may come specific data which indicates that my streaming capabilities have changed
- Update
VirtualDisplay's
parameters without recreation, so that state loss is avoided
I've found in documentation for VirtualDisplay
resize method, though it seems to have no effect on new parameters incoming. For implementation I am using
virtualDisplay = mDisplayManager.createVirtualDisplay("DispName",
getResolution().getResolutionWidth(), getResolution().getResolutionHeight(),
getDisplayDensity(), inputSurface, DisplayManager.VIRTUAL_DISPLAY_FLAG_PRESENTATION);
where inputSurface
is created by mediaEncoder.createInputSurface()
and cofigured properly by this moment. So, the question is, how can I resize VirtualDisplay
? I also didn't find any examples how to do it in official sources, would appreciate any help!
UPDATE
Just forgot to mention, I've put Listener
for VirtualDisplays
and onChange
method is triggered, though check if actual metrics were changed shows negative results
Answering to my own question
The resize method of
VirtualDisplay
works pretty fine, though it was from my side misunderstanding of how to achieve very specific behaviour, when only underlying layout changes it's size, though elements are keeping their properties on smaller windowSo, in case if you want to get some kind of "scalar" resize (like everything comes bigger or smaller) you should call resize
But, whenewer your project demands some kind of resizing and making your controls
bigger, though screen comes smaller you should check your extention of your concrete
Presentation
class linked withVirtualDisplay
and just update your layout manually without havingVirtualDisplay
resizedwhere
uiHandler
could be simply obtained even in background withI hope this would be useful for somebody!