Hi, this is troublesome issue.
And solution is quite not perfect.
1) You have to modify file outside project - after cocos2d-x update you can forget changing it.
Solution: do not forget
2) There's no way to determine in this place in code if game is landscape or portrait. I have many projects, which import this one. Some are landscape, other portrait.
Solution: make 2 projects landscape or portrait
3) Worst issue: I have virtual navigation buttons on my screen. So first time (when launching from locked screen, so bug should appear) I can see in logs:
06-30 15:34:21.090: I/System.out(1375): onSizeChanged, from: 0, 0, to: 1080, 1920
And game is initializing even after correcting width and height in 1920x1080 resolution, but this is incorrect and I can see virtual navigation keys overlapping part of the game.
Just a second later I can see second call:
06-30 15:34:21.970: I/System.out(1375): onSizeChanged, from: 1080, 1920, to: 1794, 1080
but it's too late, game is already created in wrong resolution. It should somehow refresh.
If I normally run the game I can see from: 0, 0 to 1794, 1080 and in this situation everything is ok.
Also you have reproduce it another way: rotate your phone to portrait, tap app to run it and immediately lock screen. Before it'll launch it won't have time to rotate and bug will appear.
Solution: game should reinitialize after changing orientation?
That's strange, because it should run always in landscape from the start:
this I can find in my manifest file associated with org.cocos2dx.cpp.AppActivity.