public class TrueskateActivity extends NativeActivity implements SurfaceHolder.Callback2
The in your oncreate function after super.onCreate(icicle);:
getWindow().takeSurface(null);
mySurface = new SurfaceView(this);
SurfaceHolder holder = mySurface.getHolder();
holder.addCallback(this);
setContentView(mySurface);
Then your holder callback:
@Override
public void surfaceChanged(SurfaceHolder holder, int format, int width, int height)
{
super.surfaceChanged(holder, format, mWidthScale, mHeightScale);
holder.setFixedSize(mWidthScale, mHeightScale);
android.view.ViewGroup.LayoutParams lp = mySurface.getLayoutParams();
lp.width = mWidth;
lp.height = mHeight;
mySurface.setLayoutParams(lp);
}
Then some things to watch out for:
1. Do not get the actual screen size from c++ land but instead get it from Java.
2. Do not get the returned scaled surface size from egl because certain devices give wrong values back. Work out your actual scaled screen size from step 1
3. In the surfaceChanged callback this code is important:
because if you have a landscape game and you go to the lock screen the layout can get garbled.
This works on the 30 devices I have for reference so it's pretty safe to use and it works on all firmwares. And good luck :) Shared information make the world a better place!